HP 50g User's Reference Manual
Download Advanced user's reference manual of HP 48gII Calculator for Free or View it Online on All-Guides.com.
Brand: HP
Category: Calculator
Type: Advanced user's reference manual
Model: HP 48gII , HP 49g+ , HP 50G
Pages: 693
1-36 RPL Programming
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: Comments:
«
DO
Begins the main loop.
"KEY IN a AND b" " "
INPUT OBJ→
Prompts for two numbers.
UNTIL
Starts the loop test clause.
IFERR
+
The error trap contains only the +
command.
THEN
ERRM 5 DISP
2 WAIT
0
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.
ELSE
1
If no error occurs, puts 1 (true) on the stack
for the main loop.
END
Ends the error trap.
END
Ends the main loop. If the error trap left 0
(false) on the stack, the main loop repeats —
otherwise, the program ends.
»