||THE HYPERCARD CENTER
Note: This is a work in progress and will be formatting errors. Read more about the project on the home page.
if trueOrFalse then
[else if trueOrFalse then
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.
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
add 1 to numberOfTrys
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."
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
put return & "Please enter a number between" && botNum &&¬
"and" && topNum & ":" after sayIt
Any expression that evaluates to the HyperTalk and AppleScript constants
the hilite of bg btn "Yes"
fld "Zip" contains "95014"
the short name of this stack is "Fred"
Any return-separated list of built-in commands, user-defined handlers, or keywords that are part of a message or function handler.
put "Hello world" -- built-in command
get total(field 1) -- function call
global HelpInfo -- keyword
« global | HyperTalk Reference
| if (single-statement) »
(March 24, 2022)
Switch to Modern View