Reference Guide

RPL Programming 1-13
Testing Object Types
The TYPE command (
%TEST%
L
%TYPE%
) takes any object as its argument and returns the number that
identifies that object type. For example,
"HELLO" TYPE
returns 2, the value for a string object. See the table of
object types in chapter 3, in the TYPE command, to find calculator objects and their corresponding type numbers.
Testing Linear Structure
The LININ command (
%TEST%
%LININ%
) takes an algebraic equation on level 2 and a variable
on level 1 as arguments and returns 1. if the equation is linear for that variable, or 0. if it is not. For example,
'H+Y^2' 'H' LININ
returns 1. because the equation is structurally linear for H. See the LININ command in
chapter 3 for more information.
Using Conditional Structures and Commands
Conditional structures let a program make a decision based on the results of tests.
Conditional commands let you execute a true-clause or a false-clause (each of which are a single command or object).
These conditional structures and commands are contained in the PRG BRCH menu (
%BRCH%
):
IF … THEN … END structure.
IF … THEN … ELSE … END structure.
CASE … END structure.
IFT (if-then) command.
IFTE (if-then-else) function.
The IF  THEN  END Structure
The syntax for this structure is
«
IF
test-clause
THEN
true-clause
END
»
IF … THEN … END executes the sequence of commands in the true-clause only if the test-clause evaluates to true.
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’s automatically evaluated to a number — you don’t need →NUM or EVAL.
IF begins the test-clause, which leaves a test result on 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. See
“Conditional Examples” on page 1-15.
To enter IF  THEN  END in a program:
Press
%BRCH%
!%IF%
.
The IFT Command
The IFT command takes two arguments: a test-result in level 2 and a true-clause object in level 1. If the test-result is
true, the true-clause object is executed — otherwise, the two arguments are removed from the stack. See
“Conditional Examples” on page 1-15.
To enter IFT in a program:
Press
%BRCH%
L!%IFT%
.
The IF  THEN  ELSE  END Structure
The syntax for this structure is