In addition to the standard reading procedures, MzScheme provides read-line, read-string, and read-string!:
Characters are read from port until a line separator or an end-of-file is read. The line separator is not included in the result string (but it is removed from the port's stream). If no characters are read before an end-f-file is encountered, eof is returned.
The mode argument determines the line separator(s). It must be one of the following symbols:
If n is 0, then the empty string is returned. Otherwise, if fewer than n characters are available before an end-of-file is encountered, then the returned string will contain only those characters before the end-of-file (i.e., the returned string's length will be less than n). If no characters are available before an end-of-file, then eof is returned.
If n is 0, then 0 is returned and the string is not modified. If no characters are available before an end-of-file, then eof is returned. Otherwise, the return value is the number of characters read. If m characters are read and m < start - end, then str is not modified at indices start + m though end.
In addition to the standard printing procedures, MzScheme provides print, which outputs values to a port by calling the port's print handler (see section 11.1.9):
The print procedure is used to print Scheme values in a context where a programmer expects to see a Scheme value. The rationale for providing print is that display and write both have standard output conventions, and this standardization restricts the ways that an environment can change the behavior of these procedures. No output conventions should be assumed for print so that environments are free to modify the actual output generated by print in any way. Unlike the port display and write handlers, a global port print handler can be installed through the global-port-print-handler parameter (see section 9.4.1.2).
Formatted output is written to a port with fprintf:
The return value is void.
When an illegal format string is supplied to one of these procedures, the exn:application:type exception is raised. When the format string requires more additional arguments than are supplied, the exn:application:fprintf:no-argument exception is raised. When more additional arguments are supplied than are used by the format string, the exn:application:fprintf:extra-arguments exception is raised.
For example,
(fprintf port "~a as a string is ~s.~n" '(3 4) "(3 4)")
prints this message to port:
(3 4) as a string is "(3 4)".
followed by a newline.