[ Stream I/O | Reference Manual | Alphabetic Index ]

get_stream(+StreamId, ?Stream)

Succeeds if Stream is the stream to which the stream StreamId is assigned.
StreamId
Stream alias (atom), or handle
Stream
Variable, stream handle or alias (atom)

Description

StreamId is an existing symbolic stream alias or a stream handle. If Stream is a variable, it will get bound to a stream handle corresponding to StreamId. If Stream is a symbolic stream alias or a handle, then the predicate succeeds iff StreamId and Stream denote the same stream.

The predefined symbolic system stream names are:

input, output, error, warning_output, log_output, stdin, stdout, stderr, null

Modes and Determinism

Fail Conditions

Fails if Stream is not a stream with the stream identifier StreamId

Exceptions

(4) instantiation fault
One or both of StreamId and Stream is not instantiated.
(5) type error
Stream is neither an atom, a stream handle nor a variable.
(5) type error
StreamId is neither an atom nor a stream handle.
(193) illegal stream specification
StreamId is an illegal stream specification.

Examples

Success:
      ?- get_stream(input,S).
      S = $&(stream,0)
      Yes (0.00s cpu)

      ?- set_stream(a,input), get_stream(input,a), get_stream(a,input).
      Yes (0.00s cpu)

Fail:
      set_stream(b,input), get_stream(b,output).

Error:
      get_stream(Id, S).      (Error 4).
      get_stream(1.0,S).      (Error 5).
      get_stream(3, S).       (Error 5).
      get_stream(blah,S).     (Error 193). % does not exist

See Also

set_stream / 2