HP Pascal/iX Reference Manual (31502-90022)

11- 37
The parameter is evaluated before control is passed and, its value is
available to the escapecode function.
If escape is called with no surrounding TRY-RECOVER the program aborts.
Example
PROCEDURE proc;
...
BEGIN
...
IF ( {something has gone wrong} ) THEN
ESCAPE( 0 );
...
END;
...
BEGIN
TRY
...
proc;
...
RECOVER
WRITELN( 'fatal error. program terminates' );
END.
Escapecode.
The predefined function escapecode returns the last execution error
number.
Usage
escapecode
The function returns the value passed to the last implicit or explicit
call to the predefined procedure escape.
An explicit call to escape is a call that was made by the user. In this
case escapecode returns the value of the escape code passed by the user.
An implicit call to escape is a call that was made by a subsystem on the
user's behalf or by the run-time library. In this case, escapecode
returns a predefined value based on the type of error detected. See the
HP Pascal/iX Programmer's Guide
or the
HP Pascal/HP-UX Programmer's
Guide
, depending on your implementation, for more details about the
escape code values.
If escape has never been called (implicitly or explicitly), the value
returned by escapecode is undefined. If escapecode is called outside of
the recover part of a TRY-RECOVER statement, the value returned is
undefined.
Example
TRY
...
{ perform normal processing }
RECOVER
CASE escapecode OF
...
{ fix-up after an error that can be handled }
OTHERWISE
{ send errors that cannot be handled }
escape( escapecode );
END;