pTAL Reference Manual (H06.08+)
Built-In Routines
HP pTAL Reference Manual—523746-006
15-74
$OPTIONAL
param-pair
is an actual parameter pair to pass to a formal parameter pair declared in the
called procedure if cond-expression is true. param-pair has the form:
string
is the identifier of a STRING array or simple pointer declared inside or outside
a structure.
length
is an INT expression that specifies the length, in bytes, of string.
A call to a VARIABLE or EXTENSIBLE procedure can omit some or all parameters.
$OPTIONAL lets your program pass a parameter (or parameter-pair) based on a
condition at execution time. $OPTIONAL is evaluated as follows each time the
encompassing CALL statement is executed:
•
If cond-expression is true, the parameter is passed; $PARAM, if present, is set
to true for the corresponding formal parameter.
•
If cond-expression is false, the parameter is not passed; $PARAM, if present,
is set to false for the corresponding formal parameter.
A called procedure cannot distinguish between a parameter that is passed
conditionally and one that is passed unconditionally. Passing parameters conditionally,
however, is slower than passing them unconditionally. In the first case, the
EXTENSIBLE mask is computed at execution time; in the second case, the mask is
computed at compilation time.
Example 15-68. Parameters Passed Conditionally and Unconditionally
PROC p1 (i) EXTENSIBLE;
INT i;
BEGIN
! Lots of code
END;
PROC p2;
BEGIN
INT n := 1;
CALL p1 ($OPTIONAL (n > 0, n) ); ! These two calls are
CALL p1 (n); ! indistinguishable
END;
string length
:
VST039.vsd










