The IDL_Savefile::Init function method initializes the savefile object. The SAVE file associated with the object is opened and scanned to construct an internal data structure representing the contents. The SAVE file remains open until the savefile object is destroyed; the user is not allowed to use the CLOSE procedure to close the SAVE file.

Note: Init methods are special lifecycle methods, and as such cannot be called outside the context of object creation. This means that in most cases, you cannot call the Init method directly. There is one exception to this rule: If you write your own subclass of this class, you can call the Init method from within the Init method of the subclass.


Obj = OBJ_NEW('IDL_Savefile' [, Filename ] [, FILENAME=string] [, /RELAXED_STRUCTURE_ASSIGNMENT])


Result = Obj->[IDL_Savefile::]Init()     (In a lifecycle method only.)

Return Value

When this method is called indirectly, as part of the call to the OBJ_NEW function, the return value is an object reference to the newly-created object.

When called directly within a subclass Init method, the return value is 1 (one) if initialization was successful, or 0 (zero) otherwise.



A scalar string that contains the path name of the SAVE file from which information or data is to be recovered. If Filename is not present but the FILENAME keyword is specified, the keyword value is used. If neither the argument or the keyword is present, the file idlsave.dat in IDL’s current working directory is used.



Set this keyword equal to a scalar string that contains the path name of the SAVE file from which information or data is to be recovered.

Note: The FILENAME keyword duplicates the functionality of the Filename argument. If both are provided, the value specified by the Filename argument is used.


Normally, the IDL_Savefile::Restore method is unable to restore a structure variable if the definition of its type has changed since the SAVE file was written. This commonly occurs when objects are saved and the class structures of the objects change before they are restored in another IDL session. In such cases, IDL_Savefile::Restore issues an error and does not restore the item.

Set the RELAXED_STRUCTURE_ASSIGNMENT keyword when creating a savefile object to cause the IDL_Savefile::Restore method to restore such incompatible values using “relaxed structure assignment,” in which all possible data are restored using a field-by-field copy.

See the description of the STRUCT_ASSIGN procedure for additional details.

Version History