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

get_char(+Stream, ?Char)

Reads the next character from the input stream Stream and unifies it with a single character string Char.

+Stream
Integer (stream number) or Atom (reserved or user-defined symbolic stream name).
?Char
Single character string or variable.

Description

Takes a single character string from the input stream Stream. and unifies it with Char.

Fail Conditions

Fails if Char does not unify with the next character from the buffered input stream Stream.

Resatisfiable

No.

Exceptions

(4) Instantiation fault
Stream is not instantiated.
(5) Type error
Stream is neither an integer nor an atom.
(5) Type error
Char is instantiated, but not to a single character string.
(190)
End of file has been reached.
(192)
Stream is not open for reading.
(193)
Stream is not a valid stream number.

Examples


   Success:
      [eclipse]: get_char(input,Char).
      > a
      Char = "a"
      yes.

      [eclipse]: get_char(input, "b").
      > b
      yes.

      [eclipse]: sh('cat file1').
      p
      yes.
      [eclipse]: open(file1, update,s),
      > get_char(s,X).
      X = "p"
      yes.
Fail:
      [eclipse]: get_char(input, "b").
      > a
      no.

Error:
      get_char(Stream, "b").             (Error 4).
      get_char(input, 'b').              (Error 5).
      get_char(input, 98.0).             (Error 5).
      get_char("string", Char).          (Error 5).
      get_char(null,Char).              (Error 190).
      get_char(9,Char).                 (Error 192).
      get_char(atom,Char).              (Error 193).


See Also

get / 1, get / 2, get_char / 1, put / 1, put / 2, put_char / 1, put_char / 2