
tyi(+Stream, -Code)

   Succeeds if the code of the next character read in raw mode from the
input stream Stream is successfully unified with Code.



Arguments
   Stream              Stream handle or alias (atom)
   Code                Variable or integer.

Type
   Character I/O

Description
   Takes the next character from the unbuffered input stream Stream and
   unifies its integer character code (in the range 0 to 255) with Code.  The
   input is in raw mode so that no newline character must be typed, and the
   character is not echoed on the screen.


   Character codes for the non-printable characters (i.e.  control characters)
   are also acceptable.


Note
   tyi/2 reads from the stream in raw mode.  If it is combined with the
   buffered predicates, it might happen that some characters typed ahead
   may be lost if the input device is a terminal.




Modes and Determinism
   tyi(+, -) is det

Exceptions
     4 --- Stream is not instantiated.
     5 --- Stream is neither a stream handle nor an atom.
     5 --- Code is instantiated, but not to an integer.
   190 --- End of file has been reached.
   192 --- Stream is not an input stream.
   193 --- Stream is an illegal stream specification.
   198 --- Trying to read even after the error 190 was raised.

Examples
   
Success:
      ?- tyi(input,Code).
      Code = 97         % press 'a'
      yes.

      ?- tyi(input,97).
                            % press 'a'
      yes.

      ?- tyi(input,Code).
      Code = 4          % press ^D
      yes.

Fail:
      ?- tyi(input, 0'b).
                            % press 'a'
      no.

Error:
      tyi(Stream,98).             (Error 4).
      tyi(input, '98').           (Error 5).
      tyi(input, 98.0).           (Error 5).
      tyi("string", A).           (Error 5).

      ?- open(file1,update,s), write(s,p),
         seek(s,0), tyi(s,Code),
      tyi(s,Code).              (Error 190).
      tyi(9,A).                  (Error 192).
      tyi(atom,A).               (Error 193).





See Also
   tyi / 1, tyo / 1, tyo / 2
