IF Computer > MINERVA > Manual > Reference > Predicates > Character input/output > get_code/1/2

get_code/1/2

MINERVA
ifcomputer logo
f
Expert Services on the Web

reads from a stream a single character and returns its character code.

get_code(-Char)
get_code(+Stream, -Code)

get_code/1 reads a single character from the current input stream.

get_code/2 reads a single character from the stream named in the first argument.

get_code reads the character at the current stream position and unifies its character code with Code. If the stream position is behind the end of stream, Code will be unified with -1.

Arguments

Stream                 text input stream
Code                   integer (unicode or -1)

Examples

Assume the content of a stream S is abcdefg and the stream position is at the 1st character.

get_char(S, 0'a). Succeeds. The stream position will be advanced by one character.
get_char(0'd). Fails. The stream position will be advanced by one character.

Standard

These predicates are part of the ISO-Prolog Standard.

See also

get_char/1/2, peek_char/1/2, peek_code/1/2, put_char/1/2, put_code/1/2, nl/0/1, set_input/1, current_input/1.

document: http://www.ifcomputer.co.jp/MINERVA/Manual/Reference/Predicates/char_io/get_code/print_en.html
published 2008/10/13 update 2001/8/28 (c) 1996-2006 IF Computer Japan
IF Computer 5-28-2 Sendagi, Bunkyo-ku Tel +81-3-5814-3352 start (AT) ifcomputer.com
Customer Support Tokyo 113-0022 Japan   http://www.ifcomputer.com
Back> managed with ubiCMS