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


5.12.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, #f is returned.

— Scheme Procedure: write obj [port]

Send a representation of obj to port or to the current output port if not given.

The output is designed to be machine readable, and can be read back with read (see Reading). Strings are printed in doublequotes, with escapes if necessary, and characters are printed in `#\' notation.

— Scheme Procedure: display obj [port]

Send a representation of obj to port or to the current output port if not given.

The output is designed for human readability, it differs from write in that strings are printed without doublequotes and escapes, and characters are printed as per write-char, not in `#\' form.

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

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. pstate is optional. If pstate isn't supplied and port already has a print state, the old print state is reused.

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

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)

Write message to destination, defaulting to the current output port. message can contain ~A (was %s) and ~S (was %S) escapes. When printed, the escapes are replaced with corresponding members of ARGS: ~A formats using display and ~S formats using write. If destination is #t, then use the current output port, if destination is #f, then return a string containing the formatted text. Does not add a trailing newline.

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

Send character chr to port.

— C Function: void scm_c_write (SCM port, const void *buffer, size_t size)

Write size bytes at buffer to port.

Note that this function does not update port-line and port-column (see Reading).

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

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.

The return value is unspecified.

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

Equivalent to calling force-output on all open output ports. The return value is unspecified.