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: SAVE files containing routines may not be compatible between different versions of IDL, but that files containing data are always backwards-compatible. See Creating Save Files of Program Files for details on version compatibility.
Note: While IDL routines or data can be saved in a file with any extension, it is common to use the extension .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 that can be restored, and it allows IDL to locate routines with the same base name as the file in SAVE files located in IDL’s path.
Note: 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 .pro code, you must save the object definition routine and the object instance variable in separate SAVE files, and restore both instance and definition in the target IDL session.
Note: IDL cannot save data objects that rely on state information stored in an external library. Examples of such objects include IDLffXMLDOM and IDLffJPEG2000. These objects are not stored in a SAVE file.
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'
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.
Note: 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 on the IDL Project Properties page of the Project Properties dialog.
Note: 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.
By default, any user-defined routines that are marked with "compile_opt NOSAVE" will not be included in the save file. Set the IGNORE_NOSAVE keyword to include all routines inside the save file, regardless of the compile_opt setting. See compile_opt for details.
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.
Note: SAVE (.SAV) files containing routines are not guaranteed to be compatible between successive versions of IDL. You will not be able to RESTORE SAVE files containing routines if they are made with incompatible versions of IDL. In this case, you should recompile your original code with the newer version of IDL. A SAVE file containing data will always be restorable.
Note: By default, any user-defined routines that are marked with "compile_opt NOSAVE" will not be included in the save file. To override this behavior for just a few routines, you should specify these routines as input parameters. You can also set IGNORE_NOSAVE to include all routines, regardless of the compile_opt setting. See compile_opt for details.
Note: Saving system variables is not recommended, as the structure may change between versions of IDL.
Set this keyword to print an informative message for each saved object.
Added DESCRIPTION keyword
Added EMBEDDED keyword
Added note about compile_opt NOSAVE
|8.5||Added IGNORE_NOSAVE keyword|