3.15 Input and Output

The user normally communicates with Standard LISP through “standard devices”. The default devices are selected in accordance with the conventions of the implementation site. Other input and output devices or files may be selected for reading and writing using the functions described herein.

CLOSE(FILEHANDLE:any):any eval, spread
 
Closes the file with the internal name FILEHANDLE writing any necessary end of file marks and such. The value of FILEHANDLE is that returned by the corresponding OPEN. The value returned is the value of FILEHANDLE. An error occurs if the file can not be closed.

***** FILEHANDLE could not be closed

EJECT():NIL eval, spread
 
Skip to the top of the next output page. Automatic EJECTs are executed by the print functions when the length set by the PAGELENGTH function is exceeded.

LINELENGTH(LEN:{integer, NIL}):integer eval, spread
 
If LEN is an integer the maximum line length to be printed before the print functions initiate an automatic TERPRI is set to the value LEN. No initial Standard LISP line length is assumed. The previous line length is returned except when LEN is NIL. This special case returns the current line length and does not cause it to be reset. An error occurs if the requested line length is too large for the currently selected output file or LEN is negative or zero.

***** LEN is an invalid line length

LPOSN():integer eval, spread
 
Returns the number of lines printed on the current page. At the top of a page, 0 is returned.

OPEN(FILE:any, HOW:id):any eval, spread
 
Open the file with the system dependent name FILE for output if HOW is EQ to OUTPUT, or input if HOW is EQ to INPUT. If the file is opened successfully, a value which is internally associated with the file is returned. This value must be saved for use by RDS and WRS. An error occurs if HOW is something other than INPUT or OUTPUT or the file can’t be opened.

***** HOW is not option for OPEN
***** FILE could not be opened

PAGELENGTH(LEN:{integer, NIL}):integer eval, spread
 
Sets the vertical length (in lines) of an output page. Automatic page EJECTs are executed by the print functions when this length is reached. The initial vertical length is implementation specific. The previous page length is returned. If LEN is 0, no automatic page ejects will occur.

POSN():integer eval, spread
 
Returns the number of characters in the output buffer. When the buffer is empty, 0 is returned.

PRINC(U:id):id eval, spread
 
U must be a single character id such as produced by EXPLODE or read by READCH or the value of !$EOL!$. The effect is the character U displayed upon the currently selected output device. The value of !$EOL!$ causes termination of the current line like a call to TERPRI.

PRINT(U:any):any eval, spread
 
Displays U in READ readable format and terminates the print line. The value of U is returned.
EXPR PROCEDURE PRINT(U);

   << PRIN1 U; TERPRI(); U >>;

PRIN1(U:any):any eval, spread
 
U is displayed in a READ readable form. The format of display is the result of EXPLODE expansion; special characters are prefixed with the escape character !, and strings are enclosed in ”…”. Lists are displayed in list-notation and vectors in vector-notation.

PRIN2(U:any):any eval, spread
 
U is displayed upon the currently selected print device but output is not READ readable. The value of U is returned. Items are displayed as described in the EXPLODE function with the exceptions that the escape character does not prefix special characters and strings are not enclosed in ”…”. Lists are displayed in list-notation and vectors in vector-notation. The value of U is returned.

RDS(FILEHANDLE:any):any eval, spread
 
Input from the currently selected input file is suspended and further input comes from the file named. FILEHANDLE is a system dependent internal name which is a value returned by OPEN. If FILEHANDLE is NIL the standard input device is selected. When end of file is reached on a non-standard input device, the standard input device is reselected. When end of file occurs on the standard input device the Standard LISP reader terminates. RDS returns the internal name of the previously selected input file.

***** FILEHANDLE could not be selected for input

READ():any
 
The next expression from the file currently selected for input. Valid input forms are: vector-notation, dot-notation, list-notation, numbers, function-pointers, strings, and identifiers with escape characters. Identifiers are interned onW the OBLIST (see the INTERN function in ”Identifiers”, section 3.3 on page 27). READ returns the value of !$EOF!$ when the end of the currently selected input file is reached.

READCH():id
 
Returns the next interned character from the file currently selected for input. Two special cases occur. If all the characters in an input record have been read, the value of !$EOL!$ is returned. If the file selected for input has all been read the value of !$EOF!$ is returned. Comments delimited by % and end-of-line are not transparent to READCH.

TERPRI():NIL
 
The current print line is terminated.

WRS(FILEHANDLE:any):any eval, spread
 
Output to the currently active output file is suspended and further output is directed to the file named. FILEHANDLE is an internal name which is returned by OPEN. The file named must have been opened for output. If FILEHANDLE is NIL the standard output device is selected. WRS returns the internal name of the previously selected output file.

***** FILEHANDLE could not be selected for output