IDL programs can be executed in the following ways:
To execute a batch file, enter the name of the file, prefaced with the "@" character, at the IDL prompt:
@batchfile
where batchfile is the name of the file containing IDL statements.
| Note |
For more on batch files, see Executing Batch Jobs in IDL.
To execute a Main-level program, use the .RUN or .RNEW executive command to enter the program at the IDL command line. The program will be executed automatically after you enter the END statement. To run the Main-level program again, use the .GO executive command.
For more on Main-level programs, see Main-Level Programs.
IDL program files, identified with a .pro extension, can be compiled and executed using the following methods:
To run an IDL program using the IDLDE interface, do the following:
where filename is the name of the file opened in the IDLDE editor (d_uscensus.pro, in this example).
where filename is the name of the file opened in the IDLDE editor (d_uscensus.pro, in this example).
When a file is specified by typing only the filename at the IDL prompt, IDL searches the current directory for filename.pro (where filename is the file specified) and then for filename.sav. If no file is found in the current directory, IDL searches in the same way in each directory specified by
Using the previous example, run the US Census Data demo by entering the following at the command line:
d_uscensus
When a file is specified using either the .RUN, .RNEW, .COMPILE, or @ command followed by the filename, IDL searches the current directory for filename.pro (where filename is the file specified) and then for filename.sav. If no file is found in the current directory, IDL searches in the same way in each directory specified by
| Warning |
.pro or .sav, usually) when entering the run, compile, or batch file executive command.
The details of how
IDL SAVE files (created using the SAVE procedure) can contain one or more routines that have been packaged into a single binary file. (Variables, including system variables, can also be packaged into a SAVE file: see Saving Variables from an IDL Session for a more complete discussion.)
| Note |
.sav for SAVE files. Using the .sav extension has two benefits: it makes it clear to another IDL user that the file contains IDL routines or data, and it allows IDL to locate routines with the same base name as the file in SAVE files located in IDL's path.
For an example of creating and restoring a SAVE file, see Restoring Compiled IDL Programs and Data.
Routines stored in SAVE files can be restored and executed in the following ways:
If the program you wish to run is stored in a SAVE file with the same base name as the program and the extension .sav, and the SAVE file is stored in a directory included in the IDL myroutine is stored in myroutine.sav, which is located in a directory included in
myroutine
See Automatic Compilation for additional details.
You can use the RESTORE procedure to restore all of the routines contained in a SAVE file without executing them. Once a routine has been restored, you can execute it simply by typing its name at the IDL command prompt. For example, if an IDL program named myroutine is stored in myroutine.sav, which is located in a directory that is not in
RESTORE, 'path/myroutine.sav' myroutine
where path is the full path to the myroutine.sav file. See The RESTORE Procedure for additional details.
You can use the IDL_Savefile object class to gain information about the contents of a SAVE file, and to selectively restore items from the save file. Once a routine has been restored via calls the IDL_Savefile object, you can execute it simply by typing its name at the IDL command prompt. For example, if an IDL program named myroutine is stored in myroutine.sav, which is located in a directory that is not in
obj = OBJ_NEW('IDL_Savefile', 'path/myroutine.sav')
obj->Restore, 'myroutine'
myroutine
where path is the full path to the myroutine.sav file. See The IDL_Savefile Object for additional details.