comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Common or not common
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: Common or not common [message #10379 is a reply to message #10281] Fri, 14 November 1997 00:00 Go to previous message
Liam Gumley is currently offline  Liam Gumley
Messages: 473
Registered: November 1994
Senior Member
morisset@iagusp.usp.br wrote:

> I read already lot of times David (and others) speaking
> about "never use common" (except to save values used in multiple
> call of the _same_ routine). I cannot understand how I could
> develop my codes without any common. I have a lot of routines
> that have to deal with a lot of variables (of various type).
>
> I can't imagine passing 25 or more parameters to the routines.
> And with the previous version of IDL, the parameters where
> limited in number.
>
> And what happens when I decide to add one other parameter to
> one routine? I have to check all the call to the routine
> to be sure that the new parameter is passed
> (I can't wait for IDL to do it itself ;-) ?
>
> I use parameters when I want to deal with procedure or
> function I want to apply to different variables. But when
> in every routines/functions of the program
> the spectrum, lambdas, corrections of
> different types and a lot of other things,
> have always the same name, it's easier and safer
> to pass them via a common, no?

Two words:
Structures,
Pointers.

Structures can contain anything that you would normally put in a common
block. In the simplest case, you maintain one global structure that contains
all the information you need (see any of David's example widget programs).
You define it once it your main program, or in an included file.

A pointer (or handle if you're still using IDL 4.0) to then passed to any
procedures or functions that need items from the structure (the pointer
points to the structure). Then whenever you make changes to the structure
(e.g. adding a new variable), the changes are automatically available to any
routines that use the structure. If you want to change the size or type of
an item in the structure, then instead of putting the item itself in the
structure, put a *pointer* to the item in the structure.

Trust me, it works. David wouldn't keep saying it if it didn't! Please look
at any of David's example widget programs: you will definitely learn
something. I recall reading quite a while ago (maybe it was in one of
David's manuals) that the first step to becoming a proficient in IDL is
learning how to *think* like an IDL programmer, not a FORTRAN programmer.

Cheers,
Liam.
PS: David I'll take that case of beer whenever you're ready.
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: FFT-bug???? (PV-Wave)
Next Topic: Use of IDL for Wound Care imaging

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 10:24:56 PDT 2025

Total time taken to generate the page: 1.20137 seconds