7.16 DEC-10 compatibility input/output
7.16.1 Introduction
The DEC-10 Prolog I/O predicates manipulate streams implicitly since they
only refer to current input/output streams (section 7.10.1).
The current input and output streams are initially set to
user_input and user_output respectively. The predicate
see/1
(resp. tell/1, append/1) can be used for setting the
current input (resp. output) stream to newly opened streams for
particular files. The predicate seen/0
(resp. told/0) close the current input (resp. output) stream,
and resets it to the standard input (resp. output). The predicate
seeing/1 (resp. telling/1) is used for retrieving
the file name associated with the current input (resp. output)
stream. The file name user stands for the standard input or
output, depending on context (user_input and
user_output can also be used). The DEC-10 Prolog I/O predicates
are only provided for compatibility, they are now obsolete and
their use is discouraged. The predicates for explicit stream manipulation
should be used instead (section 7.10).
7.16.2 see/1,
tell/1,
append/1
Templates
-
see(+source_sink)
see(+stream)
tell(+source_sink)
tell(+stream)
append(+source_sink)
append(+stream)
Description
see(FileName) sets the current input stream to FileName.
If there is a stream opened by see/1 associated with the same
FileName already, then it becomes the current input stream.
Otherwise, FileName is opened for reading and becomes the current
input stream.
tell(FileName) sets the current output stream to FileName.
If there is a stream opened by tell/1 associated with the same
FileName already, then it becomes the current output stream.
Otherwise, FileName is opened for writing and becomes the current
output stream.
append(FileName) like tell/1 but
FileName is opened for writing + append.
A stream-term (obtained with any other built-in predicate) can also be
provided as FileName to these predicates.
Errors
See errors associated with open/4 (section 7.10.6).
Portability
GNU Prolog predicates.
7.16.3 seeing/1,
telling/1
Templates
-
seeing(?source_sink)
telling(?source_sink)
Description
seeing(FileName) succeeds if FileName unifies
with the name of the current input file, if it was opened by
see/1; else with the current input stream-term, if this is not
user_input, otherwise with
user.
telling(FileName) succeeds if FileName unifies with the
name of the current output file, if it was opened by tell/1 or
append/1; else with the current output stream-term, if this is not
user_output, otherwise with user.
Errors
None.
Portability
GNU Prolog predicates.
7.16.4 seen/0,
told/0
Templates
-
seen
told
Description
seen closes the current input, and resets it to
user_input.
told closes the current output, and resets it to
user_output.
Errors
None.
Portability
GNU Prolog predicates.
7.16.5 get0/1,
get/1,
skip/1
Templates
-
get0(?in_character_code)
get(?in_character_code)
skip(+character_code)
Description
get0(Code) succeeds if Code unifies with the next
character code read from the current input stream. Thus it is equivalent to
get_code(Code) (section 7.12.1).
get(Code) succeeds if Code unifies with the next character
code read from the current input stream that is not a layout character.
skip(Code) skips just past the next character code Code
from the current input stream.
Errors
See errors for get_code/2 (section 7.12.1).
Portability
GNU Prolog predicates.
7.16.6 put/1,
tab/1
Templates
-
put(+character_code)
tab(+evaluable)
Description
put(Code) writes the character whose code is Code onto the
current output stream. It is equivalent to put_code(Code)
(section 7.12.5).
tab(N) writes N spaces onto the current output
stream. N may be an arithmetic expression.
Errors
See errors for put_code/2 (section 7.12.5) and for arithmetic
expressions (section 7.6.1).
Portability
GNU Prolog predicates.
Copyright (C) 1999-2007 Daniel Diaz
Verbatim copying and distribution of this entire article is permitted in any
medium, provided this notice is preserved.
More about the copyright