stream_position/[2,3]
stream_position(
+Stream, -Current)
True when Current represents the current position of Stream.
stream_position(
+Stream, -Current, +New)
Unifies the current position of the read/write pointer for Stream with Current, then sets the position to New.
A stream position
object is represented by a special Prolog term. The only safe way of
obtaining such an object is via stream_position/3
or
stream_position/2
. You should not try to construct, change, or
rely on the form of this object. It may vary under different
operating systems and/or change in subsequent versions of Quintus Prolog. On
some systems, a stream position object currently has the form:
'$stream_position'(CharCount, LineCount, LinePos, Magic1, Magic2)
Character count, line count
and line position determine the position of the pointer in the stream.
Such information is found by using character_count/2
,
line_count/2
and line_position/2
.
stream_position/2
may be used on any stream at all: streams that
are connected to disk files, streams that are connected to
sockets, streams that are connected to the terminal (including
the standard streams user_input
, user_output
,
user_error
), and even streams defined using QP_make_stream()
.
stream_position/3
may only be used on streams that are
connected to disk files.
Standard term comparison of two stream position objects for the same
stream will work as one expects. When SP1 and SP2 refer
to positions in the same stream, SP1
@<
SP2 if and only if
SP1 is before SP2 in the stream.
Stream errors (see ref-iou-sfh-est), plus:
type_error
instantiation_error
To find the current position of a stream without changing it, one can ask
| ?- stream_position(Stream, Current).
seek/4
, open/[3,4]
,
character_count/2
, line_count/2
, line_position/2
.
ref-iou