Page 21-66
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
@)ERROR
sub-menu,
entering
„
@)IFERR
, or
‚
@)IFERR
, 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
Dimension.
However, with the error-trapping construct of the program,
@ERR1
, with the same
arguments produces: [0.262295…, 0.442622…].
Summary of Contents for 50G
Page 1: ...HP g graphing calculator user s guide H Edition 1 HP part number F2229AA 90006 ...
Page 130: ...Page 2 70 The CMDS CoMmanDS menu activated within the Equation Writer i e O L CMDS ...
Page 206: ...Page 5 29 LIN LNCOLLECT POWEREXPAND SIMPLIFY ...
Page 257: ...Page 7 20 ...
Page 383: ...Page 11 56 Function KER Function MKISOM ...
Page 715: ...Page 21 68 Whereas using RPL there is no problem when loading this program in algebraic mode ...
Page 858: ...Page L 5 ...