next up previous

12.4.2.1 Open

The open function allows a user to open a file from the RHS of a rule and attaches a logical name to it. This function takes three arguments: (1) the name of the file to be opened; (2) the logical name which will be used by other CLIPS I/O functions to access the file; and (3) an optional mode specifier. The mode specifier must be one of the following strings:

Mode Means

If the mode is not specified, a default of read access only is assumed. The access mode may not be meaningful in some operating systems.

Syntax

(open <file-name> <logical-name> [<mode>])

The <filename> must either be a string or symbol and may include directory specifiers. If a string is used, the backslash (\) and any other special characters that are part of <file-name> must be escaped with a backslash. The logical name should not have been used previously. The open function returns TRUE if it was successful, otherwise FALSE.

Example

CLIPS> (open "myfile.clp" writeFile "w")
TRUE
CLIPS> (open "MS-DOS\\directory\\file.clp" readFile)
TRUE
CLIPS>


next up previous