FILE I/O FUNCTIONS


Note that initially, when starting XLISP-PLUS, there are six system stream symbols which are associated with three streams. *TERMINAL-IO* is a special stream that is bound to the keyboard and display, and allows for interactive editing. *STANDARD-INPUT* is bound to standard input or to *TERMINAL-IO* if not redirected. *STANDARD-OUTPUT* is bound to standard output or to *TERMINAL-IO* if not redirected. *ERROR-OUTPUT* (error message output), *TRACE-OUTPUT* (for TRACE and TIME functions), and *DEBUG-IO* (break loop i/o, and messages) are all bound to *TERMINAL-IO*. Standard input and output can be redirected on most systems.

File streams are printed using the #< format that cannot be read by the reader. Console, standard input, standard output, and closed streams are explicitly indicated. Other file streams will typically indicate the name of the attached file.

When the transcript is active (either -t on the command line or the DRIBBLE function), all characters that would be sent to the display via *TERMINAL-IO* are also placed in the transcript file.

*TERMINAL-IO* should not be changed. Any other system streams that are changed by an application should be restored to their original values.


READ A CHARACTER FROM A STREAM

(read-char [<stream>[<eofp>[<eof>]]])

NOTE: New eof arguments are incompatible with older XLISP versions.


PEEK AT THE NEXT CHARACTER

(
peek-char [<flag> [<stream>]])


WRITE A CHARACTER TO A STREAM

(
write-char <ch> [<stream>])


READ A LINE FROM A STREAM

(
read-line [<stream>[<eofp>[<eof>]]])

NOTE: New eof arguments are incompatible with older XLISP versions.


OPEN A FILE STREAM

(
open <fname> &key :direction :element-type :if-exists :if-does-not-exist)

The function OPEN has been significantly enhanced over original XLISP. The original function only had the :direction keyword argument, which could only have the values :input or :output. When used with the :output keyword, it was equivalent to (open <fname> :direction :output :if-exists :supersede). A maximum of ten files can be open at any one time, including any files open via the LOAD, DRIBBLE, SAVE and RESTORE commands. The open command may force a garbage collection to reclaim file slots used by unbound file streams.


CLOSE A FILE STREAM

(
close <stream>)

The stream becomes a "closed stream." Note that unbound file streams are closed automatically during a garbage collection.


DELETE A FILE

(
delete-file <fname>)


OBTAIN THE FILE PATH NAME

(
truename <fname>)


EVALUATE USING A FILE

(
with-open-file (<var> <fname> [<karg>...]) [<expr>...])

Defined in common.lsp as a macro. File will always be closed upon completion


READ A BYTE FROM A STREAM

(
read-byte [<stream>[<eofp>[<eof>]]])

NOTE: New eof arguments are incompatible with older XLISP versions.


WRITE A BYTE TO A STREAM

(
write-byte <byte> [<stream>])


GET LENGTH OF FILE

(file-length <stream>)

For an ascii file, the length reported may be larger than the number of characters read or written because of CR conversion.


GET OR SET FILE POSITION

(file-position <stream> [<expr>])

For an ascii file, the file position may not be the same as the number of characters read or written because of CR conversion. It will be correct when using file-position to position a file at a location earlier reported by file-position.


XLISP-PLUS - Version 2.1g - Tom Almy tom.almy@tek.com - 18 JUL 94
Generated with
WebMaker