Structural Informatics Group (SIG) logo
Home | Projects | Demos | Downloads | Publications | Local Info | About Us | New site
Go to the first, previous, next, last section, table of contents.

read-byte

read-byte

type: function (subr) 
location: built-in
source file: xlfio.c  
Common LISP compatible: similar
supported on: all machines

SYNTAX

(read-byte  [ <source> ]  )
        <source>        -       an optional source - must be a file pointer
                                or stream, the default is *standard-input*

DESCRIPTION

The READ-BYTE function reads a single character from the specified <source>. The character read is returned as an integer value for the result. The <source> may be a file pointer or a stream. If there is no <source>, *STANDARD-INPUT* is the default. If an end-of-file is encountered in the <source>, then NIL will be returned as the result.

EXAMPLES

(setq fp (open "f" :direction :output)) ; set up file
(print 12.34 fp)                        ;
(close fp)                              ;
                                        ;
(setq fp (open "f" :direction :input))  ; now read the file
(read-byte fp)                          ; returns 49            "1"
(read-byte fp)                          ; returns 50            "2"
(read-byte fp)                          ; returns 46            "."
(read-byte fp)                          ; returns 51            "3"
(read-byte fp)                          ; returns 52            "4"
(read-byte fp)                          ; returns 10            "\n"
(read-byte fp)                          ; returns NIL           empty
(close fp)                              ; 

COMMON LISP COMPATIBILITY: The XLISP and Common LISP READ-BYTE functions are compatible for simple cases. They both allow for the optional <source>. However, in Common LISP, there are addition parameters which occur right after <source>. So, when porting from Common LISP to XLISP, remember there are additional arguments in Common LISP's READ-BYTE.

COMMON LISP COMPATIBILITY: Common LISP specifies that read operations with a <source> of NIL, will come from *STANDARD-INPUT*. XLISP does not read the input from *STANDARD-INPUT* with a <source> of NIL. Common LISP also specifies that a <source> of T will read from *TERMINAL-IO*. XLISP does not allow T as a valid argument for <source>.


Go to the first, previous, next, last section, table of contents.