next up previous contents index
Next: Programming Format Up: Formatted Write Previous: Writef   Contents   Index

Format

format1+Format Defined as `format(Format) :- format(Format, []).' format2+Format, +Arguments Format is an atom, list of ASCII values, or a Prolog string. Arguments provides the arguments required by the format specification. If only one argument is required and this is not a list of ASCII values the argument need not be put in a list. Otherwise the arguments are put in a list.

Special sequences start with the tilde (), followed by an optional numeric argument, followed by a character describing the action to be undertaken. A numeric argument is either a sequence of digits, representing a positive decimal number, a sequence `character, representing the ASCII value of the character (only useful for  t) or a asterisk (), in when the numeric argument is taken from the next argument of the argument list, which should be a positive integer. Actions are:

write_term2. This o

Example:


\begin{code}
simple_statistics :-
<obtain statistics> %% left to the user
form...
...~\lq .t ~2f~34\vert Inferences: ~\lq .t ~D~72\vert~n',
[RunT, Inf]),
....
\end{code}

Will output


\begin{code}
Statistics
\par Runtime: .................. 3.45 Inferences: .......... 60,345
\end{code}

format3+Stream, +Format, +Arguments As format2, but write the output on the given Stream. sformat3-String, +Format, +Arguments Equivalent to format2, but ``writes'' the result on String instead of the current output stream. Example:
\begin{code}
?- sformat(S, '~w~t~15\vert~w', ['Hello', 'World']).
\par S = ''Hello World''
\end{code}

sformat2-String, +Format Equivalent to `sformat(String, Format, []).'


next up previous contents index
Next: Programming Format Up: Formatted Write Previous: Writef   Contents   Index
Dr. Richard Botting 2001-12-12