HP Pascal/iX Reference Manual (31502-90022)

11- 20
non_protected_space := idx - 1;
END;
The previous example coerces an integer to an array of integers and keeps
accessing farther out into the array until it cannot access any further.
Note that this code assumes that:
* TRY-RECOVER traps the error condition that occurs when the array
access grows beyond the limits of the available space.
* The value of the variable idx is updated correctly when execution
is transferred to the RECOVER statement.
Declaration Section
Constant Definition
NIL.
The definition of the predefined constant NIL is expanded for the system
programming extensions.
The predefined constant NIL is compatible with any long or short pointer
type. When NIL is used in a comparison or assignment, it assumes the
pointer class (short or long) of the pointer with which it is being
compared, or to which it is being assigned.
The predefined constant NIL is compatible with any PROCEDURE/FUNCTION
type. A PROCEDURE/FUNCTION variable that has been assigned the value NIL
refers to no procedure or function.
Statements
TRY-RECOVER
A Pascal program that encounters a run-time error is aborted. Because
this is not always acceptable, the system programming extensions define
the TRY-RECOVER structured statement that allows the user to trap all
run-time errors.
The predefined procedure escape allows the user to cause a run-time error
to occur, and the predefined function escapecode allows the user to
determine the last type of error that occurred. See the section "Error
Handling Routines" for more information on escape and escapecode.
Syntax
.
The statement following the reserved word RECOVER may have a statement
label. One can jump to such a label only from within the RECOVER
statement itself.
The types of errors that are trapped by TRY-RECOVER are:
* All Pascal run-time errors (defined in Appendix A ).
* An implementation defined set of hardware errors.
* An implementation defined set of operating system detected errors.
* All user-generated error conditions (generated by calling escape).
Upon detecting an error in the execution of the body of a TRY-RECOVER
statement (the statements between the reserved words TRY and RECOVER, as
well as any procedures and functions called from such statements), the
following sequence of events occurs:
* The escape code, indicating the type of error that occurred, is
saved for later retrieval by the predefined function escapecode.