next up previous

12.4.2.4 Read

The read function allows a user to input information for a single field. All of the standard field rules (e.g., multiple symbols must be embedded within quotes) apply.

Syntax

(read [<logical-name>])

where <logicalname> is an optional parameter. If specified, read tries to read from whatever is attached to the logical file name. If <logical-name> is or is not specified, the function will read from . All the delimiters defined in section 2.3.1 can be used as delimiters. The read function always returns a primitive data type. Spaces, carriage returns, and tabs only act as delimiters and are not contained within the return value (unless these characters are included within double quotes as part of a string). If an end of file (EOF) is encountered while reading, read will return the symbol EOF. If errors are encountered while reading, the string "*** READ ERROR ***" will be returned.

Example

CLIPS> (open "data.txt" mydata "w")
TRUE
CLIPS> (printout mydata "red green")
CLIPS> (close)
TRUE
CLIPS> (open "data.txt" mydata)
TRUE
CLIPS> (read mydata)
red
CLIPS> (read mydata)
green
CLIPS> (read mydata)
EOF
CLIPS> (close)
TRUE
CLIPS>


next up previous