11.3.160 prompt/2

Synopsis

prompt(-OldPrompt, +NewPrompt)

Queries or changes the prompt string of the current input stream or an input stream Stream.

Arguments

OldPrompt
atom

The old prompt atom.

NewPrompt
atom, must be nonvar

The new prompt atom.

Description

A prompt atom is a sequence of characters that indicates the Prolog system is waiting for input when a “Read” or “Get” predicate is called. If an input stream connected to a terminal is waiting for input at the beginning of a line (at line position 0), the prompt atom will be printed through an output stream associated with the same terminal.

Prolog sets the prompt to `|: ' for every new top-level query. This is the prompt that can be changed by invoking prompt/2.

Unlike state changes such as those implemented as prolog flags, the scope of a prompt change is a goal typed at the toplevel. Therefore, the change is in force only until returning to the toplevel (prompt = `| ?- ').

To query the current prompt atom, OldPrompt and NewPrompt should be the same unbound variable.

To set the prompt, NewPrompt should be an instantiated atom.

The “Load” predicates change the prompt during the time operations are performed: If a built-in loading predicate is performed on user (such as compile(user), etc.), the prompt is set to `| '. This prompt is not affected by prompt/2.

Exceptions

instantiation_error
type_error
NewPrompt is not an atom

See Also

ref-iou-tin-cpr.


Send feedback on this subject.