prompt/[2,3]

Synopsis

prompt(-OldPrompt, +NewPrompt)

prompt(+Stream, -OldPrompt, +NewPrompt)

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

Arguments


Stream stream_object
a valid Prolog input stream.
OldPrompt atom
the old prompt atom of the stream.
NewPrompt atom
the new prompt atom of the stream.

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 of the stream will be printed through an output stream associated with the same terminal.

Prolog sets the prompt of the input stream to |:. This is the prompt that can be changed by invoking prompt/[2,3]. 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 of a stream, OldPrompt and NewPrompt should be the same unbound variable. For example:

     prompt(X, X).  prompt(user_input, X, X).
     
To set the prompt of a stream, NewPrompt should be an instantiated atom. prompt/2 queries or changes the prompt on the current Prolog input stream.

Exceptions

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


instantiation_error
NewPrompt argument is not instantiated
type_error
NewPrompt is not an atom type

Comments

The "Load" predicates change the prompt of the input stream during the time operations are performed: If a built-in loading predicate is performed on the module user (such as compile(user), etc.), the prompt string of the standard Prolog input stream, user_input (user) is set to | . This prompt is not affected by prompt/[2,3].

prompt/3 succeeds for any valid input stream. If the input stream is not a tty format stream, the Prolog system does not print out the prompt string when it is waiting input from the stream.

Normally prompts only appear on user_error when the system is waiting for input on user_input. These prompts are suppressed when user_input is not connected to a terminal, unless the +tty option to prolog(1) was specified. (See fli-ios-tty.)

For prompts to be used on streams other than user_input or user_error, the C function QP_add_tty() must be used.

See Also

QP_add_tty(), read/[1,2], read_term/[2,3], get/[1,2], get0/[1,2] fli-ios