24.11.2014 Views

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

flex Expert System Toolkit - LPIS

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

7. Knowledge Specification Language 101<br />

displayed.<br />

question choose_colours<br />

Select your colours ;<br />

choose some of red, green, yellow, blue, black,<br />

white.<br />

This is exactly equivalent to:<br />

question choose_colours<br />

Select your colours ;<br />

choose from red, green, yellow, blue, black, white.<br />

Alternatively, a group name may be given for the menu items, e.g.<br />

group colours<br />

red, green, yellow, blue, black, white.<br />

question choose_a_colour<br />

Select a colour ;<br />

choose one of colours.<br />

To actually invoke a question, use the KSL keyword ask in a directive.<br />

For example, the colours question given above will be invoked by the<br />

following <strong>flex</strong> relation.<br />

relation get_colour( C )<br />

if ask choose_a_colour<br />

and C is choose_a_colour .<br />

The Prolog query<br />

?- get_colour( C ).<br />

will display a standard menu dialog (its actual appearance will depend on the<br />

particular implementation of <strong>flex</strong> that you are using), and the user’s choice<br />

will be stored in the <strong>flex</strong> global variable choose_a_colour and returned<br />

as the value of the Prolog variable C.<br />

Note that to define get_colour/1 as an equivalent action, we would need<br />

to use the KSL check that construct.<br />

action get_colour( C ) ;<br />

do ask choose_a_colour<br />

and check that C is choose_a_colour .<br />

Explanations<br />

<strong>flex</strong> toolkit<br />

The question dialog will normally contain a button labelled Explain, which<br />

allows for explanations to be attached to questions. The user may click the<br />

Explain button and the <strong>flex</strong> programmer may provide text to be displayed<br />

at this point (using the KSL keyword because), as an explanation of why

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!