get_byte(?in_byte) [ISO]

This built-in clause reads a single byte from the current input stream, the stream is altered. The current input stream must be a binary stream that was opened for reading. An in_byte is a byte or the number -1.

see also: get_byte/2 peek_byte/1 peek_byte/2 prolog I/O put_byte/1 put_byte/2

Example
get_byte(A). Assume the current input stream has contents: 120, 66, 67, ...
A is assigned the value 120 and the stream is left as: 66, 67, ...
get_byte(117). Assume the current input stream has contents: 120, 66, 67, ...
get_byte/1 fails, and a byte was removed from the stream, the current input stream is left as: 66, 67, ...

 

Exceptions  
byte is neither a variable nor an in_byte a type_error(in_byte, Byte) is thrown
current input stream is a text stream a permission_error(input, text_stream, InputStream) is thrown, the variable InputStream is assigned the stream which was used as the input stream
current input stream has properties end_of_stream(past) and eof_action(error) a permission_error(input, past_end_of_stream, InputStream) exception is thrown

 

 

info@trinc-prolog.com