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

Graphing calculator.

Program:
«
IFERR
THEN
END
"
The IFERR ... THEN ... ELSE ... END Structure
The syntax for this structure is
« ... IFERR trap-clause
THEN error-clause ELSE normal-clause END ... "
The commands in the error-clause are executed only if an error is generated during execution of the trap-clause.
If an error occurs in the trap-clause, the error is ignored, the remainder of the trap-clause is skipped, and
program execution jumps to the error-clause. If no errors occur in the trap-clause, execution jumps to the
normal-clause at the completion of the trap-clause.
To enter IFERR ... THEN ... ELSE ... END in a program:
Press !°LL %ERROR% @%IFERR%
!
Example:
The following program prompts for two numbers, then adds them. If only one number is supplied,
the program displays an error message and prompts again.
Program:
«
DO
"KEY IN a AND b" "
"
INPUT OBJ
UNTIL
IFERR
+
THEN
ERRM 5 DISP
2 WAIT
0
ELSE
1
END
END
"
1-34 RPL Programming
WHILE
1
REPEAT
...+
END
"DONE" 1 DISP
1 FREEZE
Begins the main loop.
Prompts for two numbers.
Starts the loop test clause.
The error trap contains only the + command.
If an error occurs, recalls and displays the
Too Few Arguments message for 2 seconds,
then puts 0 (false) on the stack for the main loop.
If no error occurs, puts 1(true) on the stack for the
main loop.
Ends the error trap.
Ends the main loop. If the error trap left 0 (false) on
the stack, the main loop repeats — otherwise, the
program ends.
Starts the trap-clause.
The WHILE structure repeats
and arrays to the statistics matrix
until an error occurs.
Starts the error clause. If an error
occurs in the WHILE structure,
displays the message DONE in the
status area.
Ends the error structure.

49g+