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.

make-string-input-stream

make-string-input-stream

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

SYNTAX

(make-string-input-stream <string> [ <start-pos> [ <end-pos> ] ] )
        <string>        -       a string expression
        <start-pos>     -       an optional numeric expression, default value
                                is 0 (giving the first character of the string)
        <end-pos>       -       an optional numeric expression, default value
                                is the length of the string

DESCRIPTION

The MAKE-STRING-INPUT-STREAM function creates an unnamed stream from the <string> expression. The stream can then be used as any other stream object. The optional <start-pos> expression specifies the starting offset of the <string> expression. A <start-pos> of 0 will start with the beginning of the <string>. The optional <end-pos> expression specifies the ending offset of the <string> expression. A <end-pos> of 4 will make the fourth character the last in the stream. If the function is successful, it returns the unnamed stream object. If the string is empty, an unnamed stream is still returned. Error conditions include <start-pos> and <end-pos> being out of bounds.

EXAMPLES

(make-string-input-stream "abcdefgh")   ; returns #<Unnamed-Stream: #277e2>
(read (make-string-input-stream         ;
         "123456"))                     ; returns 123456
(read (make-string-input-stream         ;
         "123456" 1))                   ; returns 23456
(read (make-string-input-stream         ;
         "123456" 1 3))                 ; returns 23
                                        ;
(read (make-string-input-stream         ;
         "123" 0))                      ; returns 123
(read (make-string-input-stream         ;
         "123" 0 3))                    ; returns 123
(read (make-string-input-stream         ;
         "123" 2 1))                    ; returns NIL
(read (make-string-input-stream         ;
         "123" 0 4))                    ; error: string index out of 
                                        ;        bounds - 4


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