Another update from ingydotnet^djgoku
This commit is contained in:
parent
91df62d461
commit
948b86eafa
7604 changed files with 108452 additions and 22726 deletions
|
|
@ -0,0 +1,25 @@
|
|||
on run
|
||||
-- define the number to be guessed
|
||||
set numberToGuess to (random number from 1 to 10)
|
||||
-- prepare a variable to store the user's answer
|
||||
set guessedNumber to missing value
|
||||
-- start a loop (will be exited by using "exit repeat" after a correct guess)
|
||||
repeat
|
||||
try
|
||||
-- ask the user for his/her guess
|
||||
set usersChoice to (text returned of (display dialog "Guess the number between 1 and 10 inclusive" default answer "" buttons {"Check"} default button "Check"))
|
||||
-- try to convert the given answer to an integer
|
||||
set guessedNumber to usersChoice as integer
|
||||
on error
|
||||
-- something gone wrong, overwrite user's answer with a non-matching value
|
||||
set guessedNumber to missing value
|
||||
end try
|
||||
-- decide if the user's answer was the right one
|
||||
if guessedNumber is equal to numberToGuess then
|
||||
-- the user guessed the correct number and gets informed
|
||||
display dialog "Well guessed! The number was " & numberToGuess buttons {"OK"} default button "OK"
|
||||
-- exit the loop (quits this application)
|
||||
exit repeat
|
||||
end if
|
||||
end repeat
|
||||
end run
|
||||
Loading…
Add table
Add a link
Reference in a new issue