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

8- 6
Haveoptvarparm Function
A routine can use the predefined function
haveoptvarparm
to determine
whether the value that it received for a formal reference parameter was
passed as an actual parameter or defaulted.
The predefined function
haveoptvarparm
returns
true
and
false
under these
conditions:
-------------------------------------------------------------------------------------
| | | |
| Function | Returns true | Returns false |
| | | |
-------------------------------------------------------------------------------------
| | | |
|
haveoptvarparm(x)
where
x
| If the routine was passed | If the routine was not |
| is a formal reference | an actual parameter for
x
| passed an actual |
| parameter of the routine | | parameter for
x
(in which|
| that called | | case,
x
assumes its |
|
haveoptvarparm
| | default value,
nil
) |
| | | |
-------------------------------------------------------------------------------------
Example
PROGRAM prog;
$STANDARD_LEVEL 'EXT_MODCAL'$
VAR
i : integer;
PROCEDURE p (VAR x,y : integer)
OPTION DEFAULT_PARMS (x := nil, y := nil);
VAR
b : boolean;
BEGIN
b := haveoptvarparm(x); {b := true for p(i)}
b := haveoptvarparm(y); {b := false for p(i)}
END;
BEGIN
p(i); {x=i, y=nil (default)}
END.
Table 8-2 tells the value of
haveoptvarparm(x)
when the formal
parameter
x
meets the following conditions:
* Nonextension or extension.
* Its actual parameter is specified or not specified.
* It is before, the same as, or after the parameter
n
, where
n
is
the last parameter for which an actual parameter is specified.