pTAL Reference Manual (H06.08+)
Built-In Routines
HP pTAL Reference Manual—523746-006
15-75
$OPTIONAL
You can use $OPTIONAL when one procedure provides a front-end interface for
another procedure that does the actual work, as Example 15-71
on page 15-75 shows.
Example 15-69. 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 15-70. 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
$OPTIONAL (j > 2, j) ); ! Pass j if j > 2
END;
Example 15-71. $OPTIONAL Routine for a Front-End Interface (page 1 of 2)
PROC p1 (i, j) EXTENSIBLE;
INT .i;
INT .j;
BEGIN
! Lots of code
END;










