Re: Two Questions [message #4819 is a reply to message #4815] |
Wed, 09 August 1995 00:00   |
offenbrg
Messages: 31 Registered: August 1993
|
Member |
|
|
mbrown@olie.wvitcoe.wvnet.edu (Myron Brown) writes:
> Hi. I have two questions (that were not answered in the FAQ):
> 1. How do I declare global variables in IDL. I am used to writing in C
> and other such languages. Am I missing something, or shoul
> 2. How do I write programs in IDL using entities similar to C header
> files? I'd like to do things with some structure (not everyth
OK -
You will find that IDL is very unlike C in many respects. However,
these two things you are asking for can be "faked," if you wish:
1. Global variables do not exist. However, "Common blocks" can be used to
achieve the same effect. (A "common block" is a group of variables which
are declared in each function/procedure, but retain their values when out of
scope, and can be declared in as many functions/procedures as you wish).
2. There aren't C header files in IDL. However, a named structure (once
defined) can not be changed at all, so you only have to define it once.
It is possible to write a simple routine which defines your structures, like
pro define_struc
;
common STRUCTURES, x, y
x = {STRUCT1, RA:0.0, DEC:0.0, EPOCH:0.0, FLUX:0.0}
y = {STRUCT2, ON:"", OFF:0L, THIS:fltarr(10), THAT:""}
end
pro use_struct
;
common STRUCTURES, x,y
define_struc
help,x,y
end
...This would define the structures and create variables X and Y which can
be used as "prototype" versions of the structures, etc.
Good Luck!
Joel
--
"...And I am unanimous in this" - Mrs. Slocumbe
------------------------------------------------------------ ----------
| Joel D Offenberg | offenbrg@fondue.gsfc.nasa.gov |
| Hughes STX, NASA/GSFC/LASP | I get paid to stare into space. |
|
|
|