The first parameter is the destination, it determines where the
output of |
format will go.
- Send the formatted output to the current output port and return
- Return the formatted output as a string.
- Any number value
- Send the formatted output to the current error port and return
- A valid output port
- Send the formatted output to the port destination and return
The second parameter is the format string. It has a similar function
to the format string in calls to
fprintf in C.
It is output to the specified destination, but all escape sequences
are replaced by the results of formatting the corresponding sequence.
Note that escape sequences are marked with the character
(tilde), and not with a
% (percent sign), as in C.
The escape sequences in the following table are supported. When there
appears "corresponding arg', that means any of the additional
arguments, after dropping all arguments which have been used up by
escape sequences which have been processed earlier. Some of the
format characters (the characters following the tilde) can be prefixed
:@, to modify the behaviour of the
format character. How the modified behaviour differs from the default
behaviour is described for every character in the table where
- Output a single
~ (tilde) character.
- Output a newline character, thus advancing to the next output line.
- Start a new line, that is, output a newline character if not already
at the start of a line.
- Output a single space character.
- Output a single tabulator character.
- Output a page separator (formfeed) character.
- Advance to the next tabulator position.
- Pretty-print the corresponding arg.
- Output the corresponding arg like
- Output the corresponding arg like
- Output the corresponding arg as a decimal number.
- Output the corresponding arg as a hexadecimal number.
- Output the corresponding arg as an octal number.
- Output the corresponding arg as a binary number.
- Output the corresponding arg as a number word, e.g. 10 prints as
ten. If prefixed with
tenth is printed, if
:@, Roman numbers are printed.
- Output the corresponding arg as a fixed format floating point
number, such as
- Output the corresponding arg in exponential notation, such as
- This works either like
~f or like
~e, whichever produces
less characters to be written.
~f, but only with two digits after the decimal point.
- Output the corresponding arg as a complex number.
- Output the corresponding arg as a character. If prefixed with
@, it is printed like with
write. If prefixed with
:, control characters are treated specially, for example
#\newline will be printed as
- "Plural". If the corresponding arg is 1, nothing is printed
y if prefixed with
s is printed (or
ies if prefixed with
- Take the corresponding argument as a format string, and the following
argument as a list of values. Then format the values with respect to
the format string.
- Flush the output to the output port.
- Continuation lines.
- Argument jumping. Navigate in the argument list as specified by the
corresponding argument. If prefixed with
:, jump backwards in
the argument list, if prefixed by
:@, jump to the parameter
with the absolute index, otherwise jump forward in the argument list.
- Case conversion begin. If prefixed by
:, the following output
string will be capitalized, if prefixed by
@, the first
character will be capitalized, if prefixed by
:@ it will be
upcased and otherwise it will be downcased. Conversion stops when the
"Case conversion end"
~)sequence is encountered.
- Case conversion end. Stop any case conversion currently in effect.
- Conditional begin.
- Conditional separator.
- Conditional end.
- Iteration begin.
- Iteration end.
- Up and out.
- Character parameter.
~0 ... ~9, ~-, ~+
- Numeric parameter.
- Variable parameter from next argument.
- Parameter is number of remaining args. The number of the remaining
arguments is prepended to the list of unprocessed arguments.
- Parameter separators.
- Inquiry message. Insert a copyright message into the output.
If any type conversions should fail (for example when using an escape
sequence for number output, but the argument is a string), an error
will be signalled.