Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.
if trueOrFalse then
statements
[else if trueOrFalse then
statements]
[else
statements
]
end if
The multiple-statement if
structure tests the specified condition and executes one or more statements if the condition is true. You use the optional else if
or else
form to run alternative blocks of code in case the condition following if
is false.
Because each part of a complex if
structure may contain more than one statement, you must have an end if
statement at the end of the structure.
on mouseUp
put random(19) into theNumber
put 0 into botNum
put 20 into topNum
put 0 into numberOfTrys
put "I am thinking of a number between 0 and 20." & return & ¬
"Try to guess the number:" into sayIt
repeat
add 1 to numberOfTrys
ask sayIt
if the result is "Cancel" OR it is empty then exit repeat
put it into theGuess
if theGuess = theNumber then
answer "You got it! The number is" && theGuess & "." & return &¬
"You guessed in" && numberOfTrys && "attempts."
exit repeat
else if theGuess is not a number then
put theGuess && "is not a number." into sayIt
else if theGuess > topNum then
put theGuess && "is greater than" && topNum & "." into sayIt
else if theGuess < botNum then
put theGuess && "is less than" && botNum & "." into sayIt
else if theGuess < theNumber then
put "The number is greater than" && theGuess & "." into sayIt
put theGuess into botNum
else if theGuess > theNumber then
put "The number is less than" && theGuess & "." into sayIt
put theGuess into topNum
end if
put return & "Please enter a number between" && botNum &&¬
"and" && topNum & ":" after sayIt
end repeat
end mouseUp
true
or false
. true
false
the hilite of bg btn "Yes"
fld "Zip" contains "95014"
the short name of this stack is "Fred"
put "Hello world" -- built-in command
get total(field 1) -- function call
global HelpInfo -- keyword
Keywords
Version 0.7b1 (March 24, 2022)