HP Pascal/iX Reference Manual (31502-90022)

11- 22
END.
In the previous example, any errors occurring in the TRY-RECOVER in proc1
cause execution to be transferred to the recover part of the try
statement in proc1. Any errors occurring in the TRY-RECOVER in the outer
block, in the recover statement in proc1, and outside of the TRY-RECOVER
in proc1 cause execution to be transferred to the recover part of the try
statement in the outer block. Any error occurring in the recover
statement in the outer block and outside of the TRY-RECOVER statement in
outer block, aborts the program because there is no TRY-RECOVER to catch
the error.
Example
VAR
int : integer;
...
int := 0;
TRY
...
int := 1;
...
int := 2;
...
int := 3;
...
RECOVER BEGIN
...
END;
If execution is transferred to the recover statement, there is no
guarantee that the variable int has a value other than zero for the
following reasons:
* The error could have occurred anywhere within the try body. The
first assignment to int may not have been executed yet.
* Even if an assignment statement was executed, the semantics do not
guarantee that the actual location of int was updated. If the new
value of int was stored in a location other than its memory
location, then the transfer of execution to the RECOVER statement
does not update the memory location of int.
Procedures and Functions
The system programming extensions define two new formal parameter
mechanisms in addition to Pascal value and VAR formal parameters. These
mechanisms are ANYVAR and READONLY.
The system programming extensions also define an extension to the
procedure and function header syntax for specifying additional attributes
of a procedure or function. This extension is
routine options
.
Formal Parameters
The reserved words ANYVAR and READONLY can syntactically replace the
reserved word VAR in a formal parameter list specification.
ANYVAR.
This formal parameter mechanism implicitly type coerces the actual
parameter to the type of the formal parameter.
A formal ANYVAR parameter represents the actual parameter during
execution of the procedure. Any changes in the value of the formal
ANYVAR parameter alters the value of the actual parameter. Therefore, it
must be a variable-access parameter. The actual parameter may have any
type. The formal-ANYVAR parameter, however, is treated within the body
of the procedure as a variable of the type specified in its definition.
An additional hidden parameter is passed along with each actual parameter
passed to a formal ANYVAR parameter. This hidden parameter is the length
in bytes of the actual parameter. This size value can be accessed