Re: new to IDL - question about modularity [message #54581 is a reply to message #54572] |
Fri, 22 June 2007 19:46  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Josh writes:
>
> despite having five manuals on IDL in front of me, I'm having some
> trouble with writing modular code. I think it lies in my lack of
> understanding of the structure, but hopefully it's a simple issue...
>
> I'm using IDL 6.3, and have written a single .pro file that looks
> like,
>
> pro xxx
> ...
> end
>
> pro yyy
> ...
> end
>
> pro zzz
> ...
> end
>
> in an effort to break up the tasks to be done. However, within the
> zzz procedure I would like to access an array that was built in the
> xxx procedure. I realize that's not possible, and was hoping for some
> guidance as to a better way to do this.
The simplest way to do this, and maybe the only way if
there is really no connection between the three modules
in your example, is to use a common block to store the array.
If there is a connection (e.g., zzz calls xxx), then you
can pass information around by means of output keywords
or even pass a pointer variable around that can be filled
out by individual modules.
There really should be some kind of connection, or these
procedures shouldn't be in the same file. That is to say,
the only reason xxx and yyy should be in the same file
as zzz is that they are utility routines for zzz. Thus,
a common block is rarely (I almost said never) needed.
They should be able to pass all their information via
keywords and parameters. :-)
http://www.dfanning.com/tips/namefiles.html
Cheers,
David
--
David Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Sepore ma de ni thui. ("Perhaps thou speakest truth.")
|
|
|