Queries posed by the system can be classified according to the kind of input they expect, the way the input is processed, etc. Queries of the same kind form a query class.
For example, queries requiring a yes/no answer form a query class with the following characteristics:
yes
or no
, respectively, as the abstract answer;
There are built-in query classes for reading in yes/no answers, toplevel queries, debugger commands, etc.
A query class is characterized by a ground Prolog term,
which is supplied as the first argument to the query processing
predicate ask_query/4
. The characteristics of a query
class are normally described by the extendible predicate
'SU_messages':query_class(QueryClass, Prompt, InputMethod, MapMethod, FailureMode).
The arguments of the query_class
predicate have the
following meaning:
For example, a built-in input method is described by the atom
line
. This requests that a line is input from the user, and the
code-list is returned. Another built-in input method is
term(
Options)
; here, a Prolog term is read and
returned.
The input obtained using InputMethod is called raw input, as it may undergo further processing.
In addition to the built-in input methods, the user can define his/her own extensions.
For example, the built-in map method char([yes-"yY", no-"nN"])
expects a code-list as raw input, and gives the answer term
yes
or no
depending on the first non-whitespace character
of the input. For another example, the built-in map method =
requests that the raw input itself be returned as the answer
term—this is often used in conjunction with the input method
term(
Options)
.
In addition to the built-in map methods the user can define his/her own extensions.
This is used only when the mapping of raw input fails, and
the query must be repeated. This happens for example if the user typed
a character other than y or n in case of the
yes_or_no
query class. FailureMode determines what to
print before re-querying the user. Possible values are:
help_query
: print a help message, then print the text of
the query again
help
: only print the help message
query
: only print the text of the query
none
: do not print anything