--******** GetPlayerInput handler ******************
--This handler prompts the player to tell the game the range of
--numbers from which lottery ticket numbers should be selected
on GetPlayerInput()
--This variable is used to control loop execution
set ValidInput to false
repeat until ValidInput = true -- loop until valid input is collected
--Question,:how does ValidInput switch to true???
--Prompt the player to specify the range of numbers to be used
set NoRange to text returned of (display dialog ¬
"What is the highest number that can be selected when " & ¬
"creating a lottery ticket?" default answer ¬
"44" buttons {"OK"} with title GameTitle)
--The range must be at least 3 and no larger than 59
if (NoRange > 2) and (NoRange < 60) then
set NoRange to NoRange as integer --Convert the player input
--Question: Why do I need this step???? A: see page 101 "Coercion"
return NoRange -- Return the player's input
else -- Display an error message if the input is not valid
display dialog "Error: You must enter an integer value " & ¬
"between 3 and 59" with title GameTitle
end if
end repeat
end GetPlayerInput