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

Home » Public Forums » archive » new to IDL - question about modularity
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: new to IDL - question about modularity [message #54674 is a reply to message #54585] Wed, 27 June 2007 13:56 Go to previous messageGo to previous message
swingnut is currently offline  swingnut
Messages: 30
Registered: September 2005
Member
The best approach depends on what ELSE the xxx procedure is doing. On
the one hand, xxx could be building xxx as one of multiple tasks, in
which case xxx could well be left alone except for adding an argument
that will have have the array, or a structure containing the array in
one of its fields. On the other hand, if xxx doesn't do anything but
build the array, it really would be handier to make it a function. On
the other other hand, if, for example, xxx initializes a whole bunch
of variables, I'd recommend going changing xxx to be a function that
returns a structure, one of whose fields contains this array you want
for zzz. I have to say, putting it in a structure ain't a bad way to
go -- I have a template for plotting code that uses a couple of
structures (one of which is generated using FSC_Color, one of which
contains estimated bin sizes for some satellite data generated using
the header data for the satellite records I use); these structures
really make it easier to do some things and to pass a collection of
different types of data back and forth as a unit.

Making a structure is easy, you just put strings and variables
together in a certain format: {tag, variable}, or, {first tag, first
variable, second tag, second variable, ...}, where each tag will be
the name used to access the value stored in that field. To get at
values in the fields, you just store the structure in a variable and
use the variable's name with a certain operator and a tag name:

myStruct={"tagOne", firstVariable, "tagTwo", secondVariable, ...}
print, myStruct.tagOne

It can get a lot more complicated than this, but that's really not an
issue at this point based on the info you've provided.


Here's a couple of handy links about structures in IDL.

http://www.dfanning.com/tips/recursive_struct_tags.html
http://groups.google.com/group/comp.lang.idl-pvwave/browse_t hread/thread/1bca12b02ac21459/9ec919cd5115345d


----------


On Jun 22, 5:48 pm, Josh <joshuamonta...@gmail.com> wrote:
> 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.
>
> Thanks!
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Font sizes and margins changed in v8.2.2?
Next Topic: Image function: define new color table

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

Current Time: Thu Oct 09 07:11:20 PDT 2025

Total time taken to generate the page: 0.56384 seconds