pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
param-list
param-name is is the identifier of a formal parameter. You can specify up to 31 formal
parameters. An actual parameter can be up to 500 bytes. A formal parameter cannot be a
pTAL reserved word.
define-body
specifies all characters between the = and # delimiters. define-body can span multiple
source lines. Enclose character strings in quotation marks ("). To use # as part of the
define-body rather than as a delimiter, enclose the # in quotation marks or embed the #
in a character string.
DEFINE declaration requirements:
• If a DEFINE and a formal parameter have the same identifier, the formal parameter has priority
during expansion.
• A DEFINE must not reference itself.
• A DEFINE declaration must not appear within a DEFINE body; that is, do not nest a DEFINE
within a DEFINE.
• To ensure proper grouping and order of evaluation of expressions in the DEFINE body, use
parentheses around each DEFINE parameter used in an expression.
• Within the DEFINE body, place any compound statements within a BEGIN-END block.
• Directives appearing within a DEFINE body are evaluated immediately; they are not part of
the DEFINE itself.
• Expanded DEFINEs must produce correct pTAL constructs. To list the expanded DEFINEs in
the compiler listing, specify the DEFEXPAND directive before the DEFINE declarations.
Example 24 DEFINE Declarations
Parentheses direct the DEFINE body evaluation:
DEFINE value = ( (45 + 22) * 8 / 2 ) #;
Incrementing and decrementing utilities included:
DEFINE increment (x) = x := x + 1 #;
DEFINE decrement (y) = y := y - 1 #;
Loads numbers into specified bit positions:
DEFINE word_val (a, b) = ((a) '<<' 12) LOR (b) #;
When a STRUCT item and a DEFINE have the same name, the compiler issues a warning when
the STRUCT item is referenced. In Example 25 (page 99), DEFINE myname accesses the structure
item1 named in the DEFINE body. The compiler issues a warning because 2 is assigned to
mystruct.yrname, not to mystruct.myname.
Example 25 STRUCT and DEFINE Macro Items With the Same Name
PROC myproc MAIN;
BEGIN
DEFINE myname = item1#,
yrname = item2#;
STRUCT mystruct;
BEGIN
Declaring DEFINEs 99