Coyote's Guide to IDL Programming

How to "Include" a File in IDL

QUESTION: In C or C++, there is the notion of include files. Does IDL have such a thing? The reason I ask is I have defined some status constants i.e. pass, fail, unknown etc. that I'd like to use in several IDL procedures. But I don't want to define a common block for every procedure that needs to know these constants. Is there another way of doing this?

ANSWER: The "@" sign in IDL can be used more or less for this purpose. When the IDL compiler finds this character in the very first character on a command line, it treats the letters that follow as a filename and add the lines in the file to the current program module in-line. That is to say, it is as if you had typed those lines at that location in the file.

For example, suppose you put your constants in a file named constants.pro

   TRUE = 1L
   FALSE = 0L
   BRIGHT = 3e5
   DIM = -0.456

You could add those constants to the file like this:

   FUNCTION CHECK_BRIGHTNESS, test
   @constants
   IF test EQ TRUE THEN RETURN, BRIGHT ELSE RETURN, DIM
   END

Notice that there are no quote marks around the name of the file. There are not necessary here. And a .pro file extension is assumed.

Google
 
Web Coyote's Guide to IDL Programming