11.3.36 character_count/2

Synopsis

character_count(+Stream, -Count)

Obtains the total number of characters either input from or output to the open text stream Stream and unifies it with Count.

Arguments

Stream
stream_object, must be ground

A valid open text stream

Count
integer

The resulting character count of the stream

Description

A freshly opened text stream has a character count of 0. When a character is input from or output to a non-tty Prolog stream, the character count of the Prolog stream is increased by one. Character count for a tty stream reflects the total character input from or output to the tty since the tty is opened to any stream.

A nl/[0,1] operation also increases the character count of a stream by one.

The count is reset by set_stream_position/2.

Exceptions

Stream errors (see ref-iou-sfh-est).

See Also

byte_count/2, line_count/2, line_position/2, stream_position/2, set_stream_position/2, ref-iou-sfh.


Send feedback on this subject.