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. The ASCII value of the character is unified with the parameter 'in_integer', if the input stream is empty then the parameter 'in_integer' is unified with the atom 'end_of_file'.
This predicate is not part of the ISO Prolog standard, the built-in predicate char_code/2 can also be used to determine the integer ASCII value of a character.
see also: 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 | |
| get0(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, ... |
| get0(112). | Assume the current input stream has contents: q, w, r, ... get0/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 integer | a type_error(integer, 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 |