Next: , Previous: , Up: mpg-bpr   [Contents][Index]


11.3.153 peek_char/[1,2]   ISO

Synopsis

peek_char(-Char)

peek_char(+Stream, -Char)

looks ahead for next input character on the current input stream or on the input stream Stream.

Arguments

Stream

stream_object, must be ground

A valid input text stream.

Char

char or one of [end_of_file]

The resulting next input character available on the stream.

Description

peek_char/[1,2] looks ahead of the next input character of the specified input stream and unifies the character with Char. The peeked character is still available for subsequent input on the stream.

Comments

It is safe to call peek_char/[1,2] several times without actually inputting any character. For example:

| ?- peek_char(X), peek_char(X), get_char(X).
|: a

X = a

Exceptions

Stream errors (see ref-iou-sfh-est), plus:

permission_error

Trying to read beyond end of Stream

See Also

ref-iou-cin.


Send feedback on this subject.