Re: Where is the right place to define new structs? [message #26499] |
Wed, 05 September 2001 11:48 |
Stein Vidar Hagfors H[1]
Messages: 56 Registered: February 2000
|
Member |
|
|
Olaf Stetzer <olaf.stetzer@imk.fzk.de> writes:
> Hello again,
>
> just another question:
>
> I want to implement a function for thermodynamic
> calculations I need. This function needs a parameter
> set as input and returns a parameter set as output, so
> I have to define the structs which hold these sets
> somewhere.
>
> I think that the right place is in the same .pro-file
Nope. For a structure named "mystruct", put it in a file called
mystruct__define, inside a PRO called mystruct__define, with no
arguments. This will automatically be run if mystruct is not defined,
upon the first encounter of statements like
my_var = {mystruct}
E.g. mystruct__define.pro:
PRO mystruct__define
dummy = {mystruct, fielda:0.0, fieldb:"" }
END
--
------------------------------------------------------------ --------------
Stein Vidar Hagfors Haugan
ESA SOHO SOC/European Space Agency Science Operations Coordinator for SOHO
NASA Goddard Space Flight Center, Email: shaugan@esa.nascom.nasa.gov
Mail Code 682.3, Bld. 26, Room G-1, Tel.: 1-301-286-9028/240-354-6066
Greenbelt, Maryland 20771, USA. Fax: 1-301-286-0264
------------------------------------------------------------ --------------
|
|
|
|
Re: Where is the right place to define new structs? [message #26507 is a reply to message #26506] |
Wed, 05 September 2001 02:45  |
Jaco van Gorkom
Messages: 97 Registered: November 2000
|
Member |
|
|
Olaf Stetzer wrote:
> ... This function needs a parameter
> set as input and returns a parameter set as output, so
> I have to define the structs which hold these sets
> somewhere.
>
> I think that the right place is in the same .pro-file
> which holds the function but I am not sure if IDL is reading
> this definition automatically when I use the function in a
> different program.
You probably want to use the input structure before the
function is run for the first time, which is tricky at best if
the named structure is defined in the function .pro-file .
The right place to put it is in an inputstruct__define.pro file.
Look up "Automatic Structure Definition" in the online help.
Have fun,
Jaco
> ps: Maybe it is the right time of buying a book on
> IDL-coding now... :-)
It is indeed. You won't regret it, really.
|
|
|
Re: Where is the right place to define new structs? [message #26509 is a reply to message #26507] |
Wed, 05 September 2001 00:58  |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Olaf Stetzer wrote:
>
> Hello again,
>
> just another question:
>
> I want to implement a function for thermodynamic
> calculations I need. This function needs a parameter
> set as input and returns a parameter set as output, so
> I have to define the structs which hold these sets
> somewhere.
>
> I think that the right place is in the same .pro-file
> which holds the function but I am not sure if IDL is reading
> this definition automatically when I use the function in a
> different program. Here is an example:
>
> foo.pro:
>
> define structs...
>
> function code...
>
> bar.pro:
>
> use one of the structs, then
> call the fuction foo and pass
> the struct to the function.
>
> Thanks for your help,
>
> Olaf
>
> ps: Maybe it is the right time of buying a book on
> IDL-coding now... :-)
Dear Olaf,
IDL searches routines along its search path but it looks first
in the path were idl is in.
cd,current=current
print,current
You can define this path by idlde preferences path or startup.
We prefer the startup method.
Because it is necessary if you have a library and many users
all of them should have the same order of pathes.
You can define a function like
function my_func
struct={a:1}
return,struct
end
If this is saved in the search path it is loaded
by x=my_funct()
If you like named structure you can define them in the startup file
too.
Then you only have to call them by x={name of structure}
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-1)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
http://www.fz-juelich.de/icg/icg1/
============================================================ ======
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
http://www.fz-juelich.de/zb/text/publikation/juel3786.html
============================================================ ======
read something about linux / windows
http://www.suse.de/de/news/hotnews/MS.html
|
|
|