Previous Contents Next
7.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.

7.13.1 get_byte/2, get_byte/1
[default]get_byte/2@get_byte/2|textbf7.13.1htoc [default]get_byte/1@get_byte/1|textbf7.13.1htoc
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.

7.13.2 peek_byte/2, peek_byte/1
[default]peek_byte/2@peek_byte/2|textbf7.13.2htoc [default]peek_byte/1@peek_byte/1|textbf7.13.2htoc
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.

7.13.3 unget_byte/2, unget_byte/1
[default]unget_byte/2@unget_byte/2|textbf7.13.3htoc [default]unget_byte/1@unget_byte/1|textbf7.13.3htoc
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[default]max_unget@max_unget (flag)7.13.3htoc Prolog flag[default]Prolog flag@Prolog flag7.13.3htoc (section 7.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.

7.13.4 put_byte/2, put_byte/1
[default]put_byte/2@put_byte/2|textbf7.13.4htoc [default]put_byte/1@put_byte/1|textbf7.13.4htoc
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-2001 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 Contents Next