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

Home » Public Forums » archive » global variables and IDLSPEC issues
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: Global variables and IDL [message #15009 is a reply to message #11537] Tue, 13 April 1999 00:00 Go to previous messageGo to previous message
davidf is currently offline  davidf
Messages: 2866
Registered: September 1996
Senior Member
Walter Roberson (roberson@ibd.nrc.ca) writes:

> Jim Russell wrote:
>
> :I'm certain that IDL has a global variable (I remember it being mentioned in
> :Fanning's book), but don't remember how to invoke it. Maybe someone else can
> :provide that for you.
>
> Use a common block. That requires adding only one extra statement to each
> routine that uses an element of the common, and requires no other code
> changes.

I'm quite sure you didn't find a common block recommendation in
Fanning's book. :-(

What I may have recommended was to create your own *system
variable*, which is the IDL equivalent of a global variable.

For example, if I were building a large application that I
wanted to run in both a Windows and UNIX environment, and that
application has a lot of sub-directories, etc. then I can have
a great deal of trouble with filenames. For example, the
"data" directory might be E:\secret\data on the PC and
/usr/people/bob/secret/data on the UNIX machine. In fact,
every installation may have their own data directory.
Writing code that can actually find the application's
data directory could be a nightmare.

So I might write a "preferences" file for the application
that each person who installs the application has to modify
for their site. One item might be the location of the
"data directory". On the PC, this might look like this:

DEFSYSV, '!Data_Directory', 'E:\secret\data'

The UNIX user would modify this line to this:

DEFSYSV, '!Data_Directory', '/usr/people/bob/secret/data'

But now it is easy for me to write code to look in this
directory. I simply construct my filenames like this:

datafile = Filepath(Root_Dir=!Data_Directory, $
SubDir=['experiment', 'daytwo'], 'exper12a.dat')

In the past 7-8 years I've found more use for GOTOs than
I have for common blocks, and I NEVER use a GOTO if I
can avoid it. :-)

Cheers,

David

--
David Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438 E-Mail: davidf@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Reading DXF?
Next Topic: Help for Wav

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

Current Time: Thu Oct 09 22:27:15 PDT 2025

Total time taken to generate the page: 0.16171 seconds