These procedures are in structure
(make-string-input-port string) -> input-port
(make-string-output-port) -> output-port
(string-output-port-output string-output-port) -> string
Make-string-input-portreturns 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-portreturns an output port that saves the characters written to it. These are then returned as a string by
(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-outputreturns. If procedure returns before writing n characters, then
limit-outputalso 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
make-tracking-output-portreturn 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-columnreturn port's current read or write location. They return
#fif port does not keep track of its location.
Fresh-linewrites a newline character to output-port if
(current-rowis 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))
Previous: Hash tables | Next: Fluid bindings