|
Re: Two Questions [message #4816 is a reply to message #4815] |
Wed, 09 August 1995 00:00  |
Jackel
Messages: 30 Registered: April 1993
|
Member |
|
|
In article <40ag77$dvs@post.gsfc.nasa.gov> offenbrg@fondue.gsfc.nasa.gov (Joel D. Offenberg) writes:
> 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).
While "Global" variables do not exist, System variables do. These are created
with the procedure DEFSYSV, and are globally visible. They can also be
made Read_Only, so that functions cannot change them. Personally, I prefer
common blocks, but the original poster might want to give both possibilities a
try.
Brian Jackel
University of Western Ontario
|
|
|
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. |
|
|
|
Re: Two Questions [message #4822 is a reply to message #4815] |
Tue, 08 August 1995 00:00  |
davis
Messages: 15 Registered: March 1995
|
Junior Member |
|
|
On Tue, 8 Aug 1995 16:24:20 -0400, Myron Brown <mbrown@olie.wvitcoe.wvnet.edu> wrote:
: 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
First of all, you need to get a text editor that:
1. Wraps text.
2. Does not have a 128 character line limit.
Almost any text editor will will meet these requirements.
--John
|
|
|