Previous Up Next

8.13  Byte input/output

These built-in predicates enable a single byte to be input from and output to a binary stream. -1 is returned to indicate the end-of-file.

8.13.1  get_byte/2, get_byte/1

Templates

get_byte(+stream_or_alias, ?in_byte)
get_byte(?in_byte)

Description

get_byte(SorA, Byte) succeeds if Byte unifies with the next byte read from the stream associated with the stream-term or alias SorA.

get_byte/1 applies to the current input stream.

Errors

SorA is a variable  instantiation_error
Byte is neither a variable nor an in-byte  type_error(in_byte, Byte)
SorA is neither a variable nor a stream-term or alias  domain_error(stream_or_alias, SorA)
SorA is not associated with an open stream  existence_error(stream, SorA)
SorA is an output stream  permission_error(input, stream, SorA)
SorA is associated with a text stream  permission_error(input, text_stream, SorA)
SorA has stream properties end_of_stream(past) and eof_action(error)  permission_error(input, past_end_of_stream, SorA)

Portability

ISO predicates.

8.13.2  peek_byte/2, peek_byte/1

Templates

peek_byte(+stream_or_alias, ?in_byte)
peek_byte(?in_byte)

Description

peek_byte(SorA, Byte) succeeds if Byte unifies with the next byte that will be read from the stream associated with the stream-term or alias SorA. The byte is not read.

peek_byte/1 applies to the current input stream.

Errors

SorA is a variable  instantiation_error
Byte is neither a variable nor an in-byte  type_error(in_byte, Byte)
SorA is neither a variable nor a stream-term or alias  domain_error(stream_or_alias, SorA)
SorA is not associated with an open stream  existence_error(stream, SorA)
SorA is an output stream  permission_error(input, stream, SorA)
SorA is associated with a text stream  permission_error(input, text_stream, SorA)
SorA has stream properties end_of_stream(past) and eof_action(error)  permission_error(input, past_end_of_stream, SorA)

Portability

ISO predicates.

8.13.3  unget_byte/2, unget_byte/1

Templates

unget_byte(+stream_or_alias, +byte)
unget_byte(+byte)

Description

unget_byte(SorA, Byte) pushes back Byte onto the stream associated with the stream-term or alias SorA. Byte will be the next byte read by get_byte/2. The maximum number of bytes that can be successively pushed back is given by the max_unget Prolog flag (section 8.22.1).

unget_byte/1 applies to the current input stream.

Errors

SorA is a variable  instantiation_error
Byte is a variable  instantiation_error
Byte is neither a variable nor a byte  type_error(byte, Byte)
SorA is neither a variable nor a stream-term or alias  domain_error(stream_or_alias, SorA)
SorA is not associated with an open stream  existence_error(stream, SorA)
SorA is an output stream  permission_error(input, stream, SorA)
SorA is associated with a text stream  permission_error(input, text_stream, SorA)

Portability

GNU Prolog predicates.

8.13.4  put_byte/2, put_byte/1

Templates

put_byte(+stream_or_alias, +byte)
put_byte(+byte)

Description

put_byte(SorA, Byte) writes Byte onto the stream associated with the stream-term or alias SorA.

put_byte/1 applies to the current output stream.

Errors

SorA is a variable  instantiation_error
Byte is a variable  instantiation_error
Byte is neither a variable nor a byte  type_error(byte, Byte)
SorA is neither a variable nor a stream-term or alias  domain_error(stream_or_alias, SorA)
SorA is not associated with an open stream  existence_error(stream, SorA)
SorA is an output stream  permission_error(output, stream, SorA)
SorA is associated with a text stream  permission_error(output, text_stream, SorA)

Portability

GNU Prolog predicates.


Copyright (C) 1999-2021 Daniel Diaz Verbatim copying and distribution of this entire article is permitted in any medium, provided this notice is preserved. More about the copyright
Previous Up Next