[ Character I/O | Reference Manual | Alphabetic 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.

Modes and Determinism

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 reached
End of file has been reached.
(192) illegal stream mode
Stream is not open for reading.
(193) illegal stream specification
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