pTAL Reference Manual (G06.24+, H06.09+, J06.03+)

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 289 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;
Example 290 Parameters Omitted 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 ( ); ! indistinguishable
END;
Example 291 Parameters Passed Conditionally
PROC p1 (str:len, b) EXTENSIBLE;
STRING .str;
INT len;
INT b;
BEGIN
! Lots of code
END;
PROC p2;
BEGIN
STRING .s[0:79];
INT i:= 1;
INT j:= 1;
CALL p1 ($OPTIONAL (i < 9, s:i), ! Pass s:i if i < 9
334 Built-In Routines