Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
5. Questions And Answers 52<br />
Customized Input<br />
The range of standard questions provided will inevitably not cover all<br />
possible situations. For this reason, <strong>flex</strong> allows customized questions in<br />
which the programmer can specify both how to obtain an answer, and what<br />
form that answer should take. The onus is totally on the programmer to<br />
present the question to the user (for example create a dialog) and to return<br />
the appropriate answer. This is indicated by the KSL keyword answer.<br />
question my_question<br />
answer is K such that ask_my_question( K ) .<br />
In this case no predefined dialog will be presented, but a call will be made to<br />
ask_my_question/1: this may be defined as a <strong>flex</strong> action, a <strong>flex</strong> relation<br />
or as a Prolog predicate. It should ask the question, creating any necessary<br />
dialogs, and return a value for the variable K.<br />
Default Questions<br />
When developing an application, it is often useful to delay the exact<br />
implementation of questions until some later stage. During this development<br />
process, <strong>flex</strong> allows you to declare a default question which is used in the<br />
absence of a specific definition. The name of the default question is<br />
catchall.<br />
question catchall<br />
Please enter data ;<br />
input name .<br />
Whenever a question is asked for which there is no definition, the<br />
catchall definition is used instead. In this case, the default answer will be<br />
of type name.<br />
Explaining Questions<br />
In addition to the form of a question, you can optionally attach an<br />
explanation to any of the standard question types (as you can with rules)<br />
using a because clause.<br />
The explanation itself can either be some canned text to be displayed, or it<br />
can be the name of a file to be browsed over. The explanations are<br />
presented whenever the end-user requests them (usually there is an Explain<br />
button in the built-in question dialogs).<br />
<strong>flex</strong> toolkit