Reference Guide

3-112 Full Command and Function Reference
See also: ABCUV, EGCD, IABCUV
IF
Type: Command Operation
Description: IF Conditional Structure Command: Starts IF … THEN … END and IF … THEN … ELSE
END conditional structures.
Conditional structures, used in combination with program tests, enable a program to make decisions.
IF … THEN … END executes a sequence of commands only if a test returns a nonzero (true)
result. The syntax is:
IF test-clause THEN true-clause END
IF begins the test clause, which must return a test result to the stack. THEN removes the test
result from the stack. If the value is nonzero, the true clause is executed. Otherwise, program
execution resumes following END.
IF … THEN … ELSE … END executes one sequence of commands if a test returns a true
(nonzero) result, or another sequence of commands if that test returns a false (zero) result. The
syntax is:
IF test-clause THEN true-clause ELSE false-clause END
IF begins the test clause, which must return a test result to the stack. THEN removes the test
result from the stack. If the value is nonzero, the true clause is executed. Otherwise, the false
clause is executed. After the appropriate clause is executed, execution resumes following END.
In RPL mode, the test clause can be a command sequence (for example,
A B
) or an algebraic
(for example,
'A‰B'
). If the test clause is an algebraic, it is automatically evaluated to a number
(→NUM or EVAL isn’t necessary).
Access:
BRANCH IF
( °is the left-shift of the Nkey).
Input/Output:
Level 1/Argument 1 Level 1/Item 1
IF
THEN
T/F
END
IF
THEN
T/F
ELSE
END
See also: CASE, ELSE, END, IFERR, THEN
IFERR
Type: Command
Description: If Error Conditional Structure Command: Starts IFERR … THEN … END and IFERR …
THEN … ELSE … END error trapping structures.
Error trapping structures enable program execution to continue after a “trapped” error occurs.
IFERR … THEN … END executes a sequence of commands if an error occurs. The syntax of
IFERR … THEN … END is:
IFERR trap-clause THEN error-clause END
If an error occurs during execution of the trap clause:
1
The error is ignored.
2
The remainder of the trap clause is discarded.