These procedures are in structure extended-ports
.
(make-string-input-port string) -> input-port
(make-string-output-port) -> output-port
(string-output-port-output string-output-port) -> string
Make-string-input-port
returns an input port that
that reads characters from the supplied string. An end-of-file
object is returned if the user reads past the end of the string.
Make-string-output-port
returns an output port that saves
the characters written to it.
These are then returned as a string by string-output-port-output
.
Procedure is called on an output port. Output written to that port is copied to output-port until n characters have been written, at which point(read (make-string-input-port "(a b)"))->
'(a b) (let ((p (make-string-output-port))) (write '(a b) p) (let ((s (string-output-port-output p))) (display "c" p) (list s (string-output-port-output p))))->
'("(a b)" "(a b)c")
limit-output
returns.
If procedure returns before writing n characters, then
limit-output
also returns at that time, regardless of how many
characters have been written.
(make-tracking-input-port input-port) -> input-port
(make-tracking-output-port output-port) -> output-port
(current-row port) -> integer or #f
(current-column port) -> integer or #f
(fresh-line output-port)
Make-tracking-input-port
and make-tracking-output-port
return ports that keep track of the current row and column and
are otherwise identical to their arguments.
Closing a tracking port does not close the underlying port.
Current-row
and current-column
return
port's current read or write location.
They return #f
if port does not keep track of its location.
Fresh-line
writes a newline character to output-port if
(current-row port
)
is not 0.
(define p (open-output-port "/tmp/temp")) (list (current-row p) (current-column p))->
'(0 0) (display "012" p) (list (current-row p) (current-column p))->
'(0 3) (fresh-line p) (list (current-row p) (current-column p))->
'(1 0) (fresh-line p) (list (current-row p) (current-column p))->
'(1 0)
Previous: Hash tables | Next: Fluid bindings