# HP 48gII Advanced User's Reference Manual Page 40

Graphing calculator.

The IF ... THEN ... ELSE ... END Structure
The syntax for this structure is
« ... IF test-clause
THEN true-clause ELSE false-clause END ... "
IF ... THEN ... ELSE ... END executes either the true-clause sequence of commands if the true-clause is true,
or the false-clause sequence of commands if the true-clause is false. 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, the false-clause is executed. After the appropriate
clause is executed, execution resumes following END. See "Conditional Examples" on page 1-15.
To enter IF ... THEN ... ELSE ... END in a program:
Press !°%BRCH% @%#IF#% .
!
The IFTE Function
The algebraic syntax for this function is 'IFTE( test, true-clause, false-clause)'
If test evaluates true, the true-clause algebraic is evaluated — otherwise, the false-clause algebraic is evaluated.
You can also use the IFTE function with stack syntax. It takes three arguments: a test-result in level 3, a true-
clause object in level 2, and a false-clause object in level 1. See "Conditional Examples" on page 1-15.
To enter IFTE in a program or in an algebraic:
Press !°%BRCH% L!%IFTE% .
!
The CASE ... END Structure
The syntax for this structure is
« ... CASE
THEN true-clause
test-clause
1
THEN truet-clause
test-clause
2
...
THEN true-clause
test-clause
n
default-clause (optional)
END ... "
The CASE ... END structure lets you execute a series of test-clause commands, then execute the appropriate
true-clause sequence of commands. The first test that returns a true result causes execution of the corresponding
true-clause, ending the CASE ... END structure. Optionally, you can include after the last test a default-clause
that's executed if all the tests evaluate to false. If a test-clause is an algebraic, it's automatically evaluated to a
number — you don't need "NUM or EVAL.
When CASE is executed, test-clause
skips to END. If test-clause
continues until a true-clause is executed, or until all the test-clauses evaluate to false. If a default clause is
included, it's executed if all the test-clauses evaluate to false. See "Conditional Examples" below.
1-14 RPL Programming
END
1
END
2
END
n
is evaluated. If the test is true, true-clause
1
is false, execution proceeds to test-clause
1
is executed, and execution
1
. Execution within the CASE structure
2

49g+

Symbols: 0