Page 21-47
The IF…THEN…END construct
The IF…THEN…END is the simplest of the IF program constructs. The general
format of this construct is:
IF
logical_statement
THEN
program_statements
END
.
The operation of this construct is as follows:
1. Evaluate
logical_statement.
2. If logical_statement is true, perform program _statements and continue
program flow after the END statement.
3. If logical_statement is false, skip program_statements and continue
program flow after the END statement.
To type in the particles IF, THEN, ELSE, and END, use:
„°
@)@BRCH@ @)@IF@@
The functions
@@@IF@@ @@THEN @@ELSE@ @@ END@@
are available in that menu to be typed
selectively by the user. Alternatively, to produce an IF…THEN…END
construct directly on the stack, use:
„°
@)@BRCH@
„
@)@IF@@
This will create the following input in the stack:
With the cursor
in front of the IF statement prompting the user for the logical
statement that will activate the IF construct when the program is executed.
Example: Type in the following program:
«
→
x
«
IF
‘
x<3
’
THEN
‘
x^2
‘
EVAL END
”
Done
”
MSGBOX
»
»