[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Global variables and IDL
- Subject: Re: Global variables and IDL
- From: Struan Gray <struan.gray(at)sljus.lu.se>
- Date: 27 Apr 1999 12:22:02 GMT
- Distribution: world
- Newsgroups: comp.lang.idl-pvwave
- Organization: This line intentionally left bland
- References: <7eumr8$ift$1@canopus.cc.umanitoba.ca> <MPG.118b9962d61fc0c6989776@news.frii.com> <37247C49.ED7C5D65@io.harvard.edu>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:14539
David Fanning, davidf@dfanning.com writes:
> Martin Schultz (mgs@io.harvard.edu) writes:
>>
>> I feel ashamed.
>
> Uh, look, this confession business has me VERY
> nervous.
<smug_git>
I've *never* used a common block, and I strip 'em out of
any code I get from elsewhere.
</smug_git>
An alternative to common blocks that I use extensively is to
create a system variable with a unique name (it helps that I work in a
research group called 'synkrotronljusfysik') and then use it to store
the start handle of a linked list. All my global variables are stored
by name in the list. I have utility routines to add, delete, move and
modify items, and I can create hierarchies by making any list item the
start handle to a sub-list.
All my widget programs know that they can find things like user
preferences, large datasets and default directory names by looking for
the relevant named parameter in the list. When a widget dies, it's
cleanup routine deletes any variables associated only with itself. One
of the reasons I still use handles a lot (despite RSI's rather
sneering insistence that we use pointers these days) is that if a list
is created properly the whole thing can be disposed of automatically
simply by freeing the first handle.
To acheive true IDLguru status I should probably objectify the
whole thing with a singleton instead of a start handle, but it works
well enough that I'm frying other fish for now.
Struan