|IDL Reference Guide: Procedures and Functions|
The SAVE procedure saves variables, system variables, and IDL routines in a SAVE file using the XDR (eXternal Data Representation) format for later recovery by RESTORE. Note that variables and routines cannot be saved in the same file. Note also that SAVE files containing routines may not be compatible between different versions of IDL, but that files containing data are always backwards-compatible.
While IDL routines or data can be saved in a file with any extension, it is common to use the extension
Do not confuse the process of saving an instance of an object with saving its definition. A reference to an instantiated object is stored in an IDL variable, and must be saved in a SAVE file as a variable. An object definition, on the other hand, is an IDL routine, and must be saved in a SAVE file as a routine. It is important to remember that restoring an instance of an object does not restore the object's definition. If the object is defined in
IDL cannot save data objects that rely on state information stored in an external library. Examples of such objects include IDLffXMLDOM, IDLffJPEG2000, and IDLffDICOMEX. These objects are not stored in a SAVE file.
SAVE [, Var1, ..., Varn] [, /ALL] [, /COMM, /VARIABLES] [, /COMPRESS] [, DESCRIPTION=string] [, /EMBEDDED] [, FILENAME=string] [, /ROUTINES] [, /SYSTEM_VARIABLES] [, /VERBOSE]
The names of one or more variables that are to be saved. If the ROUTINES keyword is present, the Var arguments should be strings containing the names of the routines to be saved. If no Var arguments are provided, the items specified by the supplied keywords are saved.
Set this keyword to save all common blocks, system variables, and local variables from the current IDL session.
Routines and variables cannot be saved in the same file. Setting the ALL keyword does not save routines.
Set this keyword to save all main level common block definitions. Note that setting this keyword does not cause the contents of the common block to be saved unless the VARIABLES keyword is also set.
If COMPRESS is set, IDL writes all data to the SAVE file using the ZLIB compression library to reduce its size. IDL's SAVE file compression support is based on the freely available ZLIB library by Mark Adler and Jean-loup Gailly.
Compressed SAVE files can be restored by the RESTORE procedure in exactly the same manner as any other SAVE file. The only visible differences are that the files will be smaller, and writing and reading them will be somewhat slower under typical conditions.
Set this keyword equal to a string that will be saved in the SAVE file:
SAVE, data, $ DESCRIPTION="Solar Obs: 2452884.9, 40 deg 0' N 105 deg 16' W"
This string can be later recovered using the RESTORE procedure or the IDL_Savefile object class. The ability to associate a descriptive string to a SAVE file can be used by IDL programs to identify data, and can also be used as an aid in managing large collections of data.
Set this keyword to request that the generated SAVE file contain an embedded license. The SAVE procedure will add an embedded license to the SAVE file if the IDL session has access to a Developer's Kit license. Use of this keyword is equivalent to selecting the Licensed Save File (.sav) option in the Project Options dialog. (See Setting the Options for a Project for details.)
Use this keyword with the ROUTINES keyword.
A string containing the name of the file into which the IDL objects should be saved. While there are no arbitrary limitations on the name of a file created with the SAVE procedure, use the
.sav extension for your files for consistency. If this keyword is not specified, the file
idlsave.dat is used.
Set this keyword to save user defined procedures and functions in a machine independent, binary form. If parameters are present, they must be strings containing the names of the procedures and/or functions to be saved. If no parameters are present, all compiled routines are saved. Routines and variables cannot be saved in the same file.
Set this keyword to save the current state of all system variables.
Saving system variables is not recommended, as the structure may change between versions of IDL.
Set this keyword to save all variables in the current program unit. This option is the default.
Set this keyword to print an informative message for each saved object.
Save the status of all currently-defined variables in the file
variables1.sav by entering:
SAVE, /VARIABLES, FILENAME = 'variables1.sav'
The variables can be restored with the RESTORE procedure.
Save the user procedures MYPROC and MYFUN:
SAVE, /ROUTINES, 'MYPROC', 'MYFUN', FILENAME = 'myroutines.sav'
IDL Online Help (March 06, 2007)