Availability:built-in
set_stream(+Stream,
+Attribute)Modify an attribute of an existing stream. Attribute
specifies the stream property to set. If stream is a pair (see stream_pair/3)
both streams are modified, unless the property is only meaningful on one
of the streams or setting both is not meaningful. In particular,
eof_action
only applies to the read stream,
representation_errors
only applies to the write
stream and trying to set alias
or line_position
on a pair results in a permission_error
exception. See also
stream_property/2
and open/4.
- alias(AliasName)
- Set the alias of an already created stream. If AliasName is
the name of one of the standard streams, this stream is rebound. Thus,
set_stream(S,
current_input)
is the same as set_input/1,
and by setting the alias of a stream to user_input
, etc.,
all user terminal input is read from this stream. See also interactor/0.
- buffer(Buffering)
- Set the buffering mode of an already created stream. Buffering is one of
full
, line
or false
.
- buffer_size(+Size)
- Set the size of the I/O buffer of the underlying stream to Size
bytes.
- close_on_abort(Bool)
- Determine whether or not the stream is closed by abort/0.
By default, streams are closed.
- close_on_exec(Bool)
- Set the
close_on_exec
property. See stream_property/2.
- encoding(Atom)
- Defines the mapping between bytes and character codes used for the
stream. See section
2.19.1 for supported encodings. The value
bom
causes the stream to check whether the current
character is a Unicode BOM marker. If a BOM marker is found, the
encoding is set accordingly and the call succeeds. Otherwise the call
fails.
- eof_action(Action)
- Set end-of-file handling to one of
eof_code
, reset
or
error
.
- file_name(FileName)
- Set the filename associated to this stream. This call can be used to set
the file for error locations if Stream corresponds to
FileName and is not obtained by opening the file directly
but, for example, through a network service.
- line_position(LinePos)
- Set the line position attribute of the stream. This feature is intended
to correct position management of the stream after sending a terminal
escape sequence (e.g., setting ANSI character attributes). Setting this
attribute raises a permission error if the stream does not record
positions. See line_position/2
and stream_property/2
(property
position
).
- locale(+Locale)
- Change the locale of the stream. See section
4.23.
- newline(NewlineMode)
- Set input or output translation for newlines. See corresponding
stream_property/2
for details. In addition to the detected modes, an input stream can be
set in mode
detect
. It will be set to dos
if a \r
character was removed.
- timeout(Seconds)
- This option can be used to make streams generate an exception if it
takes longer than Seconds before any new data arrives at the
stream. The value infinite (default) makes the stream block
indefinitely. Like wait_for_input/3,
this call only applies to streams that support the select() system call.
For further information about timeout handling, see wait_for_input/3.
The exception is of the form
error(timeout_error(read, Stream)
, _)
- type(Type)
- Set the type of the stream to one of
text
or binary
.
See also open/4
and the encoding
property of streams. Switching to binary
sets the encoding to octet
. Switching to
text
sets the encoding to the default text encoding.
- record_position(Bool)
- Do/do not record the line count and line position (see line_count/2
and line_position/2).
Calling
set_stream(S, record_position(true))
resets the
position the start of lineĀ 1.
- representation_errors(Mode)
- Change the behaviour when writing characters to the stream that cannot
be represented by the encoding. See also stream_property/2
and
section 2.19.1.
- tty(Bool)
- Modify whether Prolog thinks there is a terminal (i.e. human
interaction) connected to this stream. On Unix systems the initial value
comes from isatty(). On Windows, the initial user streams are supposed
to be associated to a terminal. See also stream_property/2.