writef.pl -- Old-style formatted write
This library provides writef/1 and friends. These predicates originate from Edinburgh C-Prolog and and provided for compatibility purposes. New code should use format/1, format/2 and friends, which are currently supported by more Prolog implementations.
The writef-family of predicates conflicts with the modern character-esacapes flag about the interpretation of \-sequences. This can be avoided by
- Disable character escapes (not recommended unless one wants to run really outdated code unmodified).
- Double the \ for conflicting interpretations
- Use ISO compliant alternatives for conflicting interpretations
- writef(+Format) is det
- writef(+Format, +Arguments) is det
- Formatted write to the
current_output
. Format is a format specifier. Some escape sequences require arguments that must be provided in the list Arguments. There are two types of escape sequences: special characters start with\
and include arguments start with%
. The special character sequences are:\n
Output a newline character \l
Output a line separator (same as \n
)\r
Output a carriage-return character (ASCII 13) \r
Output a TAB character (ASCII 9) \\
Output \
\%
Output %
\nnn
Output character <nnn>. <nnn> is a 1-3 decimal number Escape sequences to include arguments from Arguments. Each time a %-escape sequence is found in Format the next argument from Arguments is formatted according to the specification.
%t
print/1 the next item (mnemonic: term) %w
write/1 the next item %q
writeq/1 the next item %d
display/1 the next item %n
Put the next item as a character %r
Write the next item N times where N is the second item (an integer) %s
Write the next item as a String (so it must be a list of characters) %f
Perform a ttyflush/0 (no items used) %Nc
Write the next item Centered in N columns. %Nl
Write the next item Left justified in N columns. %Nr
Write the next item Right justified in N columns. - swritef(-String, +Format) is det
- swritef(-String, +Format, +Arguments) is det
- Use writef/1 or writef/2 and write the result to a string.
Note that this is a string in the sense of string_codes/2,
not a list of
character(-code)
s.
Re-exported predicates
The following predicates are exported from this file while their implementation is defined in imported modules or non-module files loaded by this module.
- writef(+Format) is det
- writef(+Format, +Arguments) is det
- Formatted write to the
current_output
. Format is a format specifier. Some escape sequences require arguments that must be provided in the list Arguments. There are two types of escape sequences: special characters start with\
and include arguments start with%
. The special character sequences are:\n
Output a newline character \l
Output a line separator (same as \n
)\r
Output a carriage-return character (ASCII 13) \r
Output a TAB character (ASCII 9) \\
Output \
\%
Output %
\nnn
Output character <nnn>. <nnn> is a 1-3 decimal number Escape sequences to include arguments from Arguments. Each time a %-escape sequence is found in Format the next argument from Arguments is formatted according to the specification.
%t
print/1 the next item (mnemonic: term) %w
write/1 the next item %q
writeq/1 the next item %d
display/1 the next item %n
Put the next item as a character %r
Write the next item N times where N is the second item (an integer) %s
Write the next item as a String (so it must be a list of characters) %f
Perform a ttyflush/0 (no items used) %Nc
Write the next item Centered in N columns. %Nl
Write the next item Left justified in N columns. %Nr
Write the next item Right justified in N columns. - swritef(-String, +Format) is det
- swritef(-String, +Format, +Arguments) is det
- Use writef/1 or writef/2 and write the result to a string.
Note that this is a string in the sense of string_codes/2,
not a list of
character(-code)
s.