next up previous contents index
Next: Terminal Control Up: Formatted Write Previous: Format   Contents   Index

Programming Format

format_predicate2+Char, +Head If a sequence  c (tilde, followed by some character) is found, the format derivatives will first check whether the user has defined a predicate to handle the format. If not, the built in formatting rules described above are used. Char is either an ASCII value, or a one character atom, specifying the letter to be (re)defined. Head is a term, whose name and arity are used to determine the predicate to call for the redefined formatting character. The first argument to the predicate is the numeric argument of the format command, or the atom default if no argument is specified. The remaining arguments are filled from the argument list. The example below redefines  n to produce Arg times return followed by linefeed (so a (Grr.) DOS machine is happy with the output).


\begin{code}
:- format_predicate(n, dos_newline(_Arg)).
\par dos_newline(Arg) :-
between(1, Ar, _), put(13), put(10), fail ; true.
\end{code}

current_format_predicate2?Code, ?:Head Enumerates all user-defined format predicates. Code is the character code of the format character. Head is unified with a term with the same name and arity as the predicate. If the predicate does not reside in module user, Head is qualified with the definition module of the predicate.


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