next up previous

12.4.2.5 Readline

The readline function is similar to the read function, but it allows a whole string to be input instead of a single field. Normally, read will stop when it encounters a delimiter. The readline function only stops when it encounters a carriage return, a semicolon, or an EOF. Any tabs or spaces in the input are returned by readline as a part of the string. The readline function returns a string.

Syntax

(readline [<logical-name>])

where <logicalname> is an optional parameter. If specified, readline tries to read from whatever is attached to the logical file name. If <logicalname> is or is not specified, the function will read from . As with the read function, if an EOF is encountered, readline will return the symbol EOF. If an error is encountered during input, readline returns the string "*** READ ERROR ***".

Example

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


next up previous