XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next

make-string-input-stream


Type:   -   function (subr)
Source:   -   xlfio.c

Syntax

(make-string-input-stream string [start-pos [end-pos]])
string - a string expression
start-pos - an optional numeric expression, default value is '0' [the first character of the string]
end-pos - an optional numeric expression, default value is the length of the string
returns - an unnamed stream that reads from 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

See the make-string-input-stream function in the XLISP 2.0 manual.

  Back to Top


XLISP > XLISP 2.0  -  Contents  -  Reference  -  Previous | Next