pTAL Reference Manual (G06.24+, H06.09+, J06.03+)
6 LITERALs and DEFINEs
A LITERAL declaration associates identifiers with constant values. A DEFINE declaration associates
identifiers (and parameters if any) with text.
You can declare LITERALs and DEFINEs once in a program, and then refer to them by identifier
many times throughout the program. They allow you to efficiently make significant changes in the
source code. You only need to change the declaration, not every reference to it in the program.
Topics:
• Declaring Literals (page 97)
• Declaring DEFINEs (page 98)
• Calling DEFINEs (page 100)
• How the Compiler Processes DEFINEs (page 100)
• Passing Actual Parameters to DEFINEs (page 100)
Declaring Literals
A LITERAL declaration specifies one or more identifiers and associates each with a constant value.
Each identifier in a LITERAL declaration is known as a LITERAL.
identifier
is the LITERAL identifier. Literal identifiers make the source code more readable. For example,
identifiers such as BUFFER_LENGTH and TABLE_SIZE are more meaningful than their respective
constant values of 80 and 128.
constant
is one of the following:
• A character string of 1 to 4 characters.
• Any of the following numeric constant expressions whose value is not the address of a
global variable (global variables are relocatable during linking):
◦ FIXED(n)
◦ INT
◦ INT(32)
◦ REAL
◦ REAL(64)
◦ UNSIGNED(n)
If you omit any constants, the compiler supplies the omitted numeric constants. The compiler uses
unsigned arithmetic to compute the constants it supplies:
• If you omit the first constant in the declaration, the compiler supplies a zero.
• If you omit a constant that follows an INT constant, the compiler supplies an INT constant that
is one greater than the preceding constant. If you omit a constant that follows a constant of
any data type except INT, an error message results.
Declaring Literals 97