Re: include files in IDL programs [message #22503] |
Fri, 17 November 2000 00:00 |
thompson
Messages: 584 Registered: August 1991
|
Senior Member |
|
|
Randall Skelton <rhskelto@atm.ox.ac.uk> writes:
> Hello all,
> This is a longshot but is there any way to have an 'include file' in IDL.
> i.e. I have a data structure which is rather complicated (and big in type)
> and I don't want to see it in every program/subroutine that I write. Is
> there anyway just to have it included with a simple '#include blah.pro' or
> somthing similar?
> Thanks in advance,
> Randall
Randall:
The way includes are done is with a "@" sign at the beginning of a line,
followed by the name of the file. Note that you can't have *any* spaces in
front of the "@" sign. For example,
PRO FXBREAD, UNIT, DATA, COL, ROW, NOSCALE=NOSCALE, VIRTUAL=VIR, $
DIMENSIONS=DIMENSIONS, NANVALUE=NANVALUE, ERRMSG=ERRMSG, $
NOIEEE=NOIEEE
@fxbintable
ON_ERROR, 2
ON_IOERROR, HANDLE_IO_ERROR
<etc>
inserts the contents of the file fxbintable.pro (in !PATH) into the program at
that point.
William Thompson
|
|
|
Re: include files in IDL programs [message #22513 is a reply to message #22503] |
Fri, 17 November 2000 00:00  |
Nando Iavarone
Messages: 48 Registered: December 1998
|
Member |
|
|
Randall Skelton wrote:
> Hello all,
>
> This is a longshot but is there any way to have an 'include file' in IDL.
> i.e. I have a data structure which is rather complicated (and big in type)
> and I don't want to see it in every program/subroutine that I write. Is
> there anyway just to have it included with a simple '#include blah.pro' or
> somthing similar?
>
> Thanks in advance,
>
> Randall
If you have a file containing code (as batch), you can use the '@filename'
to include that codes in your program.
If the case of strucured data type, it coul be better to use the __define
procedure.
For example suppose you have the structure:
struct = {structTest, $
pippo: 0L,$
pluto: lonarr(5)}
In the first case if you have the file "struct.definition",
in your code you can insert that lines using: @struct.definition
It works as "#define " of C. IDL simply replace the @struct.definition with
the contents of the file.
In the second case you can have the file "structTest__define.pro", containing
the declaration of your struct:
pro structTest__define
struct = {structTest, $
pippo: 0L,$
pluto: lonarr(5)}
end;
After structTest__define.pro compilation, in your code you can use the
statement
myStruct = {structTest}.
The difference between the two techniques is that in the first case struct is
your variable; in the second one you define a "new data type" structTest that
you can use to "declare" all variables you need:
myStruct1 = {structTest}
myStruct2 = {structTest}
myStruct1 and myStruct2 are two different variables of the same type.
bye.
|
|
|
Re: include files in IDL programs [message #22514 is a reply to message #22503] |
Fri, 17 November 2000 00:00  |
ngls
Messages: 10 Registered: November 2000
|
Junior Member |
|
|
If you're only interested in this for a structure, try using IDL's "automatic
structure definition".
If you create a PROcedure with the same name as the structure, but followed
by __DEFINE (that's two underscores) and save it as a .pro with the same name
then IDL will look for this file the when it encounters a reference to your
undefined structure. Running the code will then define the structure.
The example the online help:
PRO mystruct__define
tmp = { mystruct, a:1.0, b:'string' }
END
We use it all the time and it works a treat. The same method is used for
object definition.
Justin
rhskelto@atm.ox.ac.uk (Randall Skelton) wrote in
<Pine.LNX.4.21.0011171001370.11594-100000@mulligan.atm.ox.ac.uk>:
> Hello all,
>
> This is a longshot but is there any way to have an 'include file' in IDL.
> i.e. I have a data structure which is rather complicated (and big in type)
> and I don't want to see it in every program/subroutine that I write. Is
> there anyway just to have it included with a simple '#include blah.pro' or
> somthing similar?
>
> Thanks in advance,
>
> Randall
>
|
|
|