Next: Modal dialog
Up: No Title
Previous: Dialog primitives
dialog(Title,Top,Left,Depth,Width,Items,
Buttons, Goal)
- Goal specifies a program to be run when
the Ok button (or any button other than Cancel)
on the dialog is pressed
- If goal succeeds - dialog terminates
- If goal fails - dialog remains displayed and control
returns to the user
- Button is an integer giving the number of the
button that was pressed
- Consider the example - where the integers are expected -
and if not entered - a warning message is displayed
readints(I1,I2) :-
dialog('Integers',100,60,120,170,
[button(65,97,26,66,'Ok'),
button(68,10,20,60,'Cancel'),
text(10,10,20,150,'Enter two integers:'),
edit(34,12,20,70,'',read(I1)),
edit(34,90,20,70,'',read(I2))],
Response,
are_ints(I1,I2)).
are_ints(D, B, Int1, Int2) :-
integer(Int1),
integer(Int2), !.
are_ints(D, B, Int1, Int2) :-
message(['You must enter integers']),
fail.
Figure 17: The integer dialog
Figure 18: The integer dialog with error message
Omer F Rana
Mon Mar 17 12:45:35 GMT 1997