Interaction

Prolog's default ways of eliciting keyboard input are enumerated in the clauses for query_abbreviation/3 in messages(language('QU_messages.pl')). These clauses specify valid abbreviations for a given key word. For example,

     query_abbreviation(yes_or_no,'(y/n)',[yes-"yY",no-"nN"]).
     

A French translator might decide that the letters O and o are reasonable abbreviations for oui (yes), and therefore write yes-"oO". See the reference page for more information on query_abbreviation/3.

The query hook provides a means of overriding the default interaction. Whenever Prolog attempts to solicit input from the user, it first looks to see if the application wants to take control of the query by calling user:query_hook/6 (see the above figure). The various queries are listed in the manual page for query_hook/6. For example, if Prolog is looking for a yes-no response, as in the toplevel, this request for input can be captured as follows, where my_yes_no/2 binds Answer to yes or no:

     query_hook(toplevel,_,_,_,_,Answer):-
         my_yes_no('Done?',Answer).