Download B-Prolog User`s Manual
Transcript
• seen: Closes the current input stream. It is equivalent to
current_input(Stream),close(Stream).
• tell(FileName): Makes the file FileName the current output stream. It is
equivalent to
open(FileName,write,Stream),set_output(Stream).
• telling(FileName): The current output stream is named FileName. It is
equivalent to
current_output(Stream),
stream_property(Stream,file_name(FileName).
• told: Closes the current output stream. It is equivalent to
current_output(Stream),close(Stream).
• get(Code): Code is the next printable byte code in the current input stream.
• get0(Code): Code is the next byte code in the current input stream.
• put(Code): Outputs the character to the current output stream, whose code
is Code.
• tab(N): Outputs N spaces to the current output stream.
• exists(F): This predicate succeeds if the file F exists.
8.7
Formatted output of terms (not in ISO)
The predicate format(Format,L), which mimics the printf function in C, prints
the elements in the list L under the control of Format, which is a string of characters. There are two kinds of characters in Format: normal characters are output
verbatim, and control characters format the elements in L. Control characters all
start with ~. For example,
format("~thello~t world~t~a~t~4c~t~4d~t~7f",[atom,0’x,123,12.3])
gives the following output:
hello
world
atom
xxxx
123
12.300000
The control characters ~a, ~4c,~4d, and ~7f control the output of the atom atom,
the character 0’x, the integer 123, and the float 12.3, respectively. The control
characters ~t put the data into different columns.
44