get_code(?in_character_code) [ISO]

This built-in clause reads a single character code from the current input stream, the stream is altered. The current input stream must be a text stream that was opened for reading. An in_character_code is a character or the integer -1.

see also: get_byte/1 get_byte/2 get_char/1 get_char/2 get_code/2 peek_char/1 peek_char/2 peek_code/1 peek_code/2 prolog I/O put_char/1 put_char/2 put_code/1 put_code/2 nl/0 nl/1

Example
get_code(A). Assume the current input stream has contents: q, w, r, ...
A is assigned the value 113 and the stream is left as: w, r, ...
get_code(67). Assume the current input stream has contents: q, w, r, ...
get_code/1 fails, and a character was removed from the stream, the current input stream is left as: w, r, ...

 

Exceptions  
Code is neither a variable nor an integer a type_error(integer, Code) exception is thrown
Code is an integer but not an in_character_code a representation_error(in_character_code) exception is thrown
current input stream is a binary stream a permission_error(input, binary_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