Next: Soft Ports, Previous: File Ports, Up: Port Types
The following allow string ports to be opened by analogy to R4R* file port facilities:
Call the one-argument procedure proc with a newly created output port. When the procedure returns, return the string composed of the characters it has written into the port.
Call the one-argument procedure proc with a newly created input port from which the contents of string str's may be read. The value yielded by the proc is returned.
Connect an input port to string and call thunk with no arguments. During the call,
current-input-portreturns an input port connected to the text of string. When the thunk returns, close the port. Return the value yielded by thunk. If an escape procedure is used to escape from the continuation of these procedures, behavior is implementation dependent.
Return an input port that delivers characters from the string str. The port can be closed by
close-input-port, though its storage will be reclaimed by the garbage collector if it becomes inaccessible.
Return an output port that will accumulate characters for retrieval by
get-output-string. The port can be closed by the procedureclose-output-port, though its storage will be reclaimed by the garbage collector if it becomes inaccessible.
Given an output port created by
open-output-string, return a string consisting of the characters that have been output to the port so far.
A string port can be used in many procedures which accept a port but which are not dependent on implementation details of fports. E.g., seeking and truncating will work on a string port, but trying to extract the file descriptor number will fail.