HP Pascal/iX Reference Manual (31502-90022)

11- 38
The example above shows a possible control structure for trapping
software errors. Within the recover section of the TRY-RECOVER
statement, escapecode is used to recover information about the nature of
the error that caused the trap to the recover section. Note the use of
escapecode to pass certain errors on to a next enclosing TRY statement
with an explicit call to escape.
Parameter Mechanisms
Haveextension.
The predefined Boolean function haveextension determines if an extension
parameter is accessible.
Usage
haveextension
(parameter_name)
Parameters
parameter_name
The name of a formal parameter in the current scope
or a containing scope that is EXTENSIBLE.
In a routine with extension parameters it may be necessary to check a
formal parameter to ensure that an actual parameter was supplied, as a
result of a parameter being passed by the user or being defaulted. The
predefined function haveextension indicates, for a formal extension
parameter name, whether that parameter exists and can be accessed.
Example
PROCEDURE proc_with_opt_parms( parm1 : type1;
VAR parm2 : type2;
parm3 : type3;
VAR parm4 : type4 )
OPTION EXTENSIBLE 2;
BEGIN
...
IF (haveextension( parm4 )) THEN
{ implies that parm4 and parm3 have values }
...
IF (haveextension( parm3 )) THEN
{ implies that parm3 has values }
...
...
END;
proc_with_opt_parms( var1, var2 );
...
proc_with_opt_parms( var1, var2, var3 );
In the previous example, haveextension is used to determine whether
either or both of the EXTENSIBLE parameters are passed in the call to the
procedure. Note that if parm4 is present, then by definition parm3 must
also be present. See the description of routine OPTION EXTENSIBLE for
more information.
In the first call to proc_with_opt_parms, both calls to haveextension
return false because none of the extension parameters are passed. In the
second call, haveextension returns true for the third parameter only.
PROCEDURE proc_with_opt_parms( parm1 : type1;
VAR parm2 : type2;