HP Pascal/iX Programmer's Guide (31502-90023)

11- 2
The procedure
escape
has one parameter,
error_code
, which is an integer
expression.
Escape
sets
error_code
, whose value you can then access with
the predefined function
escapecode
.
Example
PROGRAM p;
VAR
x : integer;
ecode : integer;
.
.
PROCEDURE PUTJCW; INTRINSIC;
PROCEDURE proc (n : integer);
BEGIN {proc}
{Test for erroneous parameter}
IF NOT (n IN [0..100]) THEN
escape(-755);
.
.
putjcw(jcwname,jcwvalue,error); {system call}
IF error > 0 THEN
escape(error); {system call failed}
.
.
END; {proc}
BEGIN {main program}
TRY
proc(x);
RECOVER
ecode := escapecode; {See note in "Escapecode Function"}
IF ecode = -775 THEN
{Report bad value of m}
ELSE IF ecode = -3550 THEN
{Report failure of system call}
ELSE
halt(ecode);
END. {main program}
Escapecode Function
The predefined function
escapecode
returns the integer value of
error_code
, the parameter of the predefined procedure
escape
(see "Escape
Procedure" ).
The result of
escapecode
is undefined if
escape
was never called, and
after exit from the TRY-RECOVER construct by normal, sequential means
(rather than exit by explicit
escape, exit,
or
goto
). If you call
escapecode
when its result is undefined, the result is indeterminate and
meaningless. Access
escapecode
only in the RECOVER part of a TRY-RECOVER
construct.
To see the symbolic names for the escape codes that the Pascal
subsystem returns, list the file PASESC.PUB.SYS (on MPE/iX) or
/usr/include/pasesc.ph (on HP-UX).
TRY-RECOVER Construct
The TRY-RECOVER construct defines a group of statements as error recovery
code.
Syntax
TRY
statement
[;
statement
]... RECOVER
statement
Parameter
statement
Labeled or unlabeled statement.
If an error occurs when the program executes a
statement
(or any routines
called by the statement in the TRY part):