pTAL Reference Manual (H06.03+)
LITERALs and DEFINEs
HP pTAL Reference Manual—523746-005
6-8
Passing Actual Parameters to DEFINEs
Example 6-10 on page 6-8 shows a DEFINE declaration that has one formal parameter
and an assignment statement that uses the DEFINE identifier, passing a parameter
of 3.
Example 6-13 on page 6-9 displays a message, checks the condition code, and
assigns an error if one occurs.
Example 6-9. Parentheses in an Actual Parameter
DEFINE varproc (proc1, param) = CALL proc1 (param) #;
varproc (myproc, (i + j) * k); ! Expands to:
! CALL myproc ((i+j)*k);
Example 6-10. Assignment Statement Using DEFINE Macro Identifier
DEFINE cube (x) = ( x * x * x ) #;
INT result;
result := cube (3) '>>' 1;
! Expands to: (3 * 3 * 3) '>>' 1 = 27 '>>' 1 = 13
Example 6-11. Incrementing and Decrementing Utilities
DEFINE increment (x) = x := x + 1 #;
DEFINE decrement (y) = y := y - 1 #;
INT index := 0;
increment(index); ! Expands to: index := index + 1;
Example 6-12. Filling an Array With Zeros
DEFINE zero_array (array, length) =
BEGIN
array[0] := 0;
array[1] ':=' array FOR length - 1;
END #;
LITERAL len = 50;
INT buffer[0:len - 1];
zero_array (buffer, len); ! Fill buffer with zeros










