Next: , Previous: Reading, Up: Input and Output


27.3 Writing

[Generic procedures for writing to ports.]

— Scheme Procedure: get-print-state port
— C Function: scm_get_print_state (port)

Return the print state of the port port. If port has no associated print state, return #f.

— Scheme Procedure: display obj [port]

Send a representation of obj to current-output-port. Optional second arg port specifies an alternative output port. The representation is similar to that produced by write (REFFIXME), the differences being strings are not quoted (and their characters are not escaped), and characters are rendered as if with write-char.

— Scheme Procedure: newline [port]
— C Function: scm_newline (port) |0 |1 |0

Send a newline to port. If port is omitted, send to the current output port.

— Scheme Procedure: port-with-print-state port pstate
— C Function: scm_port_with_print_state (port, pstate)

Create a new port which behaves like port, but with an included print state pstate.

— Scheme Procedure: print-options-interface [setting]
— C Function: scm_print_options (setting) |0 |1 |0

Option interface for the print options. Instead of using this procedure directly, use the procedures print-enable, print-disable, print-set! and print-options.

— Scheme Procedure: simple-format destination message [args ...]
— C Function: scm_simple_format (destination, message, args) |2 |0 |1

Write message to destination, defaulting to the current output port. message can contain ~A (or ~a) and ~S (or ~s) escapes. When printed, the escapes are replaced with corresponding members from args: ~A formats using display and ~S formats using write.

Additionally, ~~ results in a single tilde, ~% a newline, and any other character following tilde, unless that tilde is the last character in message, signals an "unsupported format option" error. Signal "missing argument" error if there are more ~A and ~S escapes than there are args. However, the opposite (more args than substituting escapes) is ok. In that case, silently ignore leftover args.

If destination is #t, then use the current output port, if destination is #f, then return a string containing the formatted text.

— Scheme Procedure: write-char chr [port]
— C Function: scm_write_char (chr, port) |1 |1 |0

Send character chr to port.

— Scheme Procedure: force-output [port]
— C Function: scm_force_output (port) |0 |1 |0

Flush the specified output port, or the current output port if port is omitted. The current output buffer contents are passed to the underlying port implementation (e.g., in the case of fports, the data will be written to the file and the output buffer will be cleared). It has no effect on an unbuffered port.

— Scheme Procedure: flush-all-ports
— C Function: scm_flush_all_ports ()

Equivalent to calling force-output on all open output ports.