TAL Reference Manual

Standard Functions
TAL Reference Manual526371-001
14-32
$OPTIONAL Function
STRING s;
END;
STRUCT .st; !Declare structure ST
BEGIN
INT i;
INT j;
INT .st_ptr(tt !Declare structure pointer
END; ! that points to structure TT
INT x;
x := $OFFSET (st.j); !X gets 2
x := $OFFSET (tt.s); !X gets 6
x := $OFFSET (st.st_ptr.s); !X gets 6
3. This example applies $OFFSET to an indexed template structure:
INT x;
STRUCT st[-1:1];
BEGIN
INT item;
FIXED(2) price;
END;
x := $OFFSET (st[-1].item); !X gets -10
$OPTIONAL Function
The $OPTIONAL function controls whether a given parameter or parameter pair is
passed to a VARIABLE or EXTENSIBLE procedure in a D20 or later object file.
cond-expression
is a conditional expression. If cond-expression is true, param or param-pair is
passed. If
cond-expression is false, param (or param-pair) is not passed.
param
is a variable identifier or an expression that defines an actual parameter to pass to
a formal parameter declared in the called procedure if
cond-expression is true.
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:
(
cond-expression
,$OPTIONAL
param )
param-pair
VST1434.vsd