next up previous

13.11.4.3 Saving Instances to a Text File

This function saves all instances in the CLIPS environment to the specified file in the following format:

(<instance-name> of <class-name> <slot-override>*)
<slot-override> ::= (<slot-name> <single-field-value>*)

A slot-override is generated for every slot of every instance, regardless of whether the slot currently holds a default value or not. External-address and fact-address slot values are saved as strings. Instance-address slot values are saved as instance-names. This function the number of instances saved.

Syntax

(save-instances <file-name>
        [local | visible [[inherit] <class>+])

By default, save-instances saves only the instances of all defclasses in the current module. Specifying visible saves instances for all classes within scope of the current module. Also, particular classes may be specified for saving, but they must be in scope according to the local or visible option. The inherit keyword can be used to force the saving of indirect instances of named classes as well (by default only direct instances are saved for named classes). Subclasses must still be in local or visible scope in order for their instances to be saved. Unless the inherit option is specified, only concrete classes can be specified. At least one class is required for the inherit option.

The file generated by this function can be loaded by either load-instances or restore-instances. save-instances does not preserve module information, so the instance file should be loaded into the module which was current when it was saved.


next up previous