get(?in_character)

This built-in clause reads a single character 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 is a character or the atom 'end_of_file'.

This predicate is not part of the ISO Prolog standard, get_char/1 is equivalent to this predicate and defined by the ISO Prolog standard.

see also: get/2 get_byte/1 get_byte/2 get_char/2 get_code/1 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(A). Assume the current input stream has contents: q, w, r, ...
A is assigned the value q and the stream is left as: w, r, ...
get('a'). Assume the current input stream has contents: q, w, r, ...
get/1 fails, and a character was removed from the stream, the current input stream is left as: w, r, ...

 

Exceptions  
Char is neither a variable nor an in_character a type_error(in_character, Char) 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