29 lines
847 B
Text
29 lines
847 B
Text
command guessTheNumber lowN highN
|
|
local tNumber, tguess, tmin, tmax
|
|
if lowN is empty or lowN < 1 then
|
|
put 1 into tmin
|
|
else
|
|
put lowN into tmin
|
|
end if
|
|
if highN is empty then
|
|
put 10 into tmax
|
|
else
|
|
put highN into tmax
|
|
end if
|
|
put random(tmax - tmin + 1) + tmin - 1 into tNumber
|
|
repeat until tguess is tNumber
|
|
ask question "Please enter a number between" && tmin && "and" && tmax titled "Guess the number"
|
|
if it is not empty then
|
|
put it into tguess
|
|
if tguess is tNumber then
|
|
answer "Well guessed!"
|
|
else if tguess < tNumber then
|
|
answer "too low"
|
|
else
|
|
answer "too high"
|
|
end if
|
|
else
|
|
exit repeat
|
|
end if
|
|
end repeat
|
|
end guessTheNumber
|