[ ECLiPSe Stream I/O built-in.|Group Index| Full Index]

get_stream_info(+Stream, ?Attr, ?Value)

Succeeds if the attribute Attr of the open stream Stream has the value Value.

+Stream
Atom or integer denoting an open stream.
?Attr
Atom or variable.
?Value
Variable, atom, string or integer.

Description

Used to retrieve information associated to an open stream. The available attributes and their meanings are:

    Attr            Value         Description

    name            atom or       associated filename, or contents
                    string        in case of a string or queue

    device          file, null,   the device behind the stream
                    pipe, queue,
                    socket, tty,
                    string

    mode            read, write,  the stream's direction
                    update

    physical_stream integer       associated stream number

    aliases         integer       current number of symbolic names

    system_use      on, off       a system stream is currently
                                  redirected to this stream

    line            integer       current line number
                                  (input streams only)

    offset          integer       current position in the
                                  stream, as given by at/2

    prompt          string        prompt string (input streams only)

    prompt_stream   integer       output stream for the prompt
                                  (input streams only)

    fd              integer       the associated UNIX file descriptor

    port            integer       port number associated with an
                                  internet socket

    connection      atom          identification of the connected
                                  socket - file name for unix sockets,
                                  host name for internet ones

    end_of_line     cr, crlf      which end-of-line sequence to write

    flush           flush,        explicit or implicit flushing
                    end_of_line

    event           atom          event on writing to empty stream
                                  (see open/4)

    yield           on, off       yield on end-of-file (see open/4)

Fail Conditions

Fails if Value does not unify with the current value of attribute Attr, or if the requested attribute is not available.

Resatisfiable

Yes.

Exceptions

(4) Instantiation fault
Stream is not instantiated.
(5) Type error
Stream is neither an atom nor an integer.
(5) Type error
Attr is instantiated, but not to an atom.
(5) Type error
Value is instantiated, but not to an atom, string or integer.
(6) Range error
Attr is an atom, but not a valid attribute name.
(193)
Stream does not denote an open stream.

Examples


Success:
    [eclipse]: get_stream_info(input,X,Y), writeln(X is Y), fail.
    name is user
    physical_stream is 0
    aliases is 2
    system_use is on
    line is 1
    offset is 0
    prompt is  
    prompt_stream is 1
    fd is 0
    reprompt_only is off
    device is tty
    mode is read

    no (more) solution.
    [eclipse]: get_stream_info(toplevel_input, prompt, P).

    P = "\t"
    yes.

Fail:
    get_stream_info(output, prompt, P).
    get_stream_info(output, system_use, off).

Error:
    get_stream_info(X, Y, Z).                      (Error 4)
    get_stream_info(file(f), Y, Z).                (Error 5)
    get_stream_info(output, 7, X).                 (Error 5)
    get_stream_info(output, offset, 8.5).          (Error 5)
    get_stream_info(output, length, Z).            (Error 5)
    get_stream_info(nostream, Y, Z).               (Error 193)


See Also

open / 3, open / 4, current_stream / 1, get_prompt / 3, get_stream / 2, at / 2