[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Including files
- Subject: Re: Including files
- From: "J.D. Smith" <jdsmith(at)astrosun.tn.cornell.edu>
- Date: Mon, 24 May 1999 15:55:33 +0000
- Newsgroups: comp.lang.idl-pvwave
- Organization: Cornell University
- References: <7ibpsf$362$1@nntp.ucs.ubc.ca>
- Sender: jts11(at)cornell.edu (Verified)
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:14883
Nils Johnson wrote:
>
> The IDL documentation mentions include files, which allows "statements
> contained in an include file" to be "textually inserted into the including
> file."
>
> However, I can not find any mention or examples of how, exactly, to
> include other files. What is the syntax? Are there any examples in the
> documentation or sample code that comes with IDL?
>
> Nils
@foo
includes the file foo (or foo.pro) which exists in the search path. The
usual search order issues apply (multiple files foo lead to unexpected
results!).
One way this can be used to advantage is with common block definitions.
If there is not a known entry point for defining a common block which is
used by various different procedures, you must either define it
beforehand in some startup routine which the user must remember to run
or put in their startup file, or else simply define the common block in
all routines in which it's used. That is, you must use:
common cblock, var1, var2, var3, var4, ...
everywhere instead of:
common cblock
Normally this is a real pain, since changing the common block requires
changing all of its definition statements. However, if you put the
definition in one file and simply do a:
@cblock
at the beginning of all relevant procedures, you can change your common
block in one place and still not require an initializer. Of course,
eliminating the common block is another good solution, but sometimes
this can't be done.
This technique can be extended to other areas also, such as common error
checking code, etc.
Good Luck,
JD
--
J.D. Smith |*| WORK: (607) 255-5842
Cornell University Dept. of Astronomy |*| (607) 255-6263
304 Space Sciences Bldg. |*| FAX: (607) 255-5875
Ithaca, NY 14853 |*|