The high-level routines are meant to provide completely contained procedures which interact with save files. These routines are to be used either on the command line, or within other programs.
CMSAVE and CMRESTORE are drop-in, but more featureful replacements to the built-in IDL SAVE and RESTORE procedures. CMSAVEDIR allows you to print the contents of an existing save file without actually restoring it, and also to interrogate the contents of the file programmatically.
Unlike the built-in versions of RESTORE, CMRESTORE and CMSAVEDIR allow a variety of ways to access auxiliary data from a save file without actually restoring the variables from disk. The concept is that a program can scan the file and decide which actions to take based on the contents of the file, without restoring it first. This may be important for example, to prevent crucial variables from being overwritten, or to compile a class before restoring an object of that class.
For example, before restoring a file, here is a way to determine whether it contains system variables, which may be dangerous to restore:
; Extract variable names from save file cmsavedir, 'myfile.sav', n_var=nvar, var_names=vnames, /quiet ; Find any variable names with exclamation mark '!' sb = strpos(vnames, '!') wh = where(sb GE 0, count) if count GT 0 then $ message, 'WARNING: myfile.sav contains system variables'
It is also possible to pass data to CMSAVE and CMRESTORE using the DATA keyword. Data can be passed as pointers, handles or structures. This allows for maximum flexibility and convenience for the programmer.