Module char [Preloaded]

Characters can be written to text streams or read from text streams. Text streams can be obtained by the to open/3 and open/4 system predicates documented in the stream control section. The standard output and/or the standard input might also point to text streams, but this is not guaranteed. Text streams are automatically flushed when the new line primitive is invoked. Additionally the text stream of the console window is automatically flushed when more than 1024 characters have been written.

The following character input/output predicates are provided:

nl: [ISO 8.12.3]
nl(T): [ISO 8.12.3]
The predicate without arguments writes the system end of line sequence to the standard output and flushes it. The unary predicate takes an additional text stream sink as argument.
put_char(C): [ISO 8.12.3]
put_char(T, C): [ISO 8.12.3]
The unary predicate writes the character C to the standard output. The binary predicate takes an additional text stream sink as argument.
put_code(C): [ISO 8.12.3]
put_code(T, C): [ISO 8.12.3]
The unary predicate writes the code C to the standard output. The binary predicate takes an additional text stream sink as argument.
peek_char(C): [ISO 8.12.2]
peek_char(T, C): [ISO 8.12.2]
The unary predicate reads a character from the standard input and puts it back. The predicate succeeds when C unifies with the peeked character or the atom end_of_file when the end of the stream has been reached. The binary predicate takes an additional text stream source as argument.
peek_code(C): [ISO 8.12.2]
peek_code(T, C): [ISO 8.12.2]
The predicate reads a code from the standard input and puts it back. The predicate succeeds when C unifies with the read code or the integer -1 when the end of the stream has been reached. The binary predicate takes an additional text stream source as argument.
get_char(C): [ISO 8.12.1]
get_char(T, C): [ISO 8.12.1]
The predicate reads a character from the standard input. The predicate succeeds when C unifies with the read character or the atom end_of_file when the end of the stream has been reached.The binary predicate takes an additional text stream source as argument.
get_code(C): [ISO 8.12.1]
get_code(T, C): [ISO 8.12.1]
The predicate reads a code from the standard input. The predicate succeeds when C unifies with the read code or the integer -1 when the end of the stream has been reached. The binary predicate takes an additional text stream source as argument.

Kommentare