[Up] [Contents] [Index] [Summary]

3.30.1 Writef

write_ln(+Term)
Equivalent to write(Term), nl.

writef(+Atom)
Equivalent to writef(Atom, []).

writef(+Format, +Arguments)
Formatted write. Format is an atom whose characters will be printed. Format may contain certain special character sequences which specify certain formatting and substitution actions. Arguments then provides all the terms required to be output.

Escape sequences to generate a single special character:

\nOutput a nemline character (see alsonl/[0,1])
\lOutput a line separator (same as\n)
\rOutput a carriage-return character (ASCII 13)
\tOutput the ASCII character TAB (9)
\\The character\is output
\%The character%is output
\nnnwhere<nnn>is an integer (1-3 digits) the character with ASCII code<nnn>is output (NB :<nnn>is read asdecimal)

Note that \l, \\bnfmeta{nnn} and \\ are interpreted differently when character-escapes are in effect. See section 2.12.1.1.

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.

%tprint/1the next item (mnemonic: term)
%wwrite/1the next item
%qwriteq/1the next item
%ddisplay/1the next item
%pprint/1the next item (identical to%t)
%nPut the next item as a character (i.e. it is an ASCII value)
%rWrite the next item N times where N is the second item (an integer)
%sWrite the next item as a String (so it must be a list of characters)
%fPerform attyflush/0(no items used)
%NcWrite the next item Centered inNcolumns.
%NlWrite the next item Left justified inNcolumns.
%NrWrite the next item Right justified inNcolumns. Nis a decimal number with at least one digit. The item must be an atom, integer, float or string.

swritef(-String, +Format, +Arguments)
Equivalent to writef/2, but ``writes'' the result on String instead of the current output stream. Example: ?- swritef(S, '%15L%w', ['Hello', 'World']). S = "Hello World"

swritef(-String, +Format)
Equivalent to swritef(String, Format, []).