These are the components of the IFERR ... THEN ... END construct or of the
IFERR ... THEN ... ELSE ... END construct. Both logical constructs are used for
trapping errors during program execution. Within the @) E RROR sub-menu,
entering „@) I FERR, or ‚@) I FERR, will place the IFERR structure components in
the stack, ready for the user to fill the missing terms, i.e.,
The general form of the two error-trapping constructs is as follows:
IF trap-clause THEN error-clause END
IF trap-clause THEN error-clause ELSE normal-clause END
The operation of these logical constructs is similar to that of the IF ... THEN ...
END and of the IF ... THEN ... ELSE ... END constructs. If an error is detected
during the execution of the trap-clause, then the error-clause is executed.
Otherwise, the normal-clause is executed.
As an example, consider the following program (@ERR1) that takes as input two
matrices, A and b, and checks if there is an error in the trap clause: A b / (RPN
mode, i.e., A/b). If there is an error, then the program calls function LSQ (Least
SQuares, see Chapter 11) to solve the system of equations:
A b « IFERR A b / THEN LSQ END " "
Try it with the arguments A = [ [ 2, 3, 5 ] , [1, 2, 1 ] ] and b = [ [ 5 ] , [ 6 ] ].
A simple division of these two arguments produces an error: /Error: Invalid
However, with the error-trapping construct of the program, @ERR1, with the same
arguments produces: [0.262295..., 0.442622...].