Coffee Machine scenario SECTION 3 Advanced Tutorial
27
CALL Reset( )
When the coin is inserted, we want to make a sound and change the displayed
command.
1, 2, 3… 1. Copy the sound file cashreg.wav from the folder of the sample programs
to the project folder C:\Coffee.
2. Create a Page Script with Trigger Event of On Condition with an
Expression of credit == 1 and script code of :
displaytext = "Make a Selection"
PlaySound("c:\coffee\cashreg.wav")
Include a script for displaying the user selection in the Selection Display and
assign this selection to the selection variable. Use the variables selection to
store the number typed, pressed to note when the first digit has been entered
and selection_made to determine when the second digit has been entered
therefore the selection is complete.
1, 2, 3… 1. Add an Execute Script animation to the Push Button with caption "1" with
the following code:
IF pressed == TRUE THEN
selection = (selection * 10 ) + 1
pressed = FALSE
selection_made = TRUE
ELSE
selection = 1
pressed = TRUE
selection_made = FALSE
ENDIF
2. Repeat for the other buttons, replacing both the 1's with the appropriate
digit.
To round off this step, include a script to produce the selection entered by
the user. This script should:
• Display a message for informing the user what is happening.
• Display the cup and the coffee liquid.
• Play a sound file to simulate the coffee dropping, and one when
finished.
• Display a message to notify the user to pick up the coffee.
1, 2, 3… 1. Copy the sound files glu.wav and finished.wav from the folder of the
sample programs to the project folder C:\Coffee.
2. Add a page script to trigger On Condition called Make the Drink with an
expression of "(selection_made == TRUE) and (credit == 1) and (ready
== TRUE)". Add the following code:
ready = FALSE
displaytext = "Making your selection"
cup.visible( 1)
coffee.visible (1)
for time_counter = 0 to 50 'just looping for coffee animation
next
PlaySound("c:\coffee\glu.wav")