Welcome to the Harris Geospatial product documentation center. Here you will find reference guides, help documents, and product libraries.


Harris Geospatial / Docs Center / Using IDL / Using Include Files in Routines

IDL

Using Include Files in Routines

Using Include Files in Routines

Include files in IDL are .PRO files that contain IDL code and are designed to be included within other programs at compile time.

You can include these files within your routines using the @ character. For example, assume you have a file named myroutine.pro containing the following statements:

PRO myroutine
  ...code...
@myinclude.pro
  ...more code...
end

When IDL compiles myroutine.pro, it will automatically read in all of the IDL code within myinclude.pro and embed it within the program, just as if the code had been directly included within myroutine. When the end of the file is reached, compilation resumes at the line after the @.

Notes

  • Include files can be nested by placing a call to one include file within another.
  • Include files are embedded at compile time, not run time.
  • If the include statement does not contain a file extension, IDL searches the current working directory and the directories specified by !PATH for a file with the file extension .pro. If the file is not found in a given directory, IDL searches for the file with no extension. If the file includes a full path specification, IDL does not search the directories in !PATH.

  • Include files are useful for "boilerplate" code such as error handling or checking for valid input arguments.
  • All of the code within the file is embedded at the location of the @ statement. You should be cautious about including a large include file in multiple locations, as this may lead to code bloat and slower compilation. Instead, it is better to have your include file make a few calls out to helper routines.

See Also


Overview of IDL Program Types, Batch Files, Special Characters    



© 2018 Harris Geospatial Solutions, Inc. |  Legal
My Account    |    Store    |    Contact Us