The DEFINE declaration causes the compiler to save the specified text until the associated define identifier is encountered in a define invocation. At that point, the saved text is retrieved and compiled as if the text were located at the position of the define invocation.
<define declaration>
┌◄───── , ─────┐ ── DEFINE ─┴─<definition>─┴────────────────────────────────────────────┤
<definition>
──<identifier>─┬──────────────────────┬─ = ──<text>── # ───────────────┤
└─<formal symbol part>─┘<define identifier>
An identifier that is associated with text in a DEFINE declaration.
<text>
Any sequence of valid characters not including a free number sign (#) character.
Text is bracketed on the left by the equal sign (=) and on the right by the number sign (#). The equal sign is said to be matched with the number sign. The text can be any sequence of characters not containing a free number sign. A free number sign is one that is not in a string literal, not in a remark, and not matched with an equal sign in a define declaration within the text. The compiler interprets the first free number sign as signaling the end of the text. That is, the first free number sign is matched with the equal sign that started the text.
Compiler control records occurring within the text are processed normally if the dollar sign ($) is in column 1 or 2. If the dollar sign is in column 3 or beyond, a syntax error is generated whenever the define is invoked.
-
When declaring defines using included files, you should have the <text> and terminating free pound sign (#) within the same file. These two parts should either be in the same symbol file or the same include file. Failure to follow this guideline can produce unexpected results. This is known to be true for number defines, for example DEFINE A = 50#. For more information about include files, see the “INCLUDE Option” in Compiling Programs.
-
When using the compile-time facility, the DEFINE declaration is extended to include additional syntax. For more information about these DEFINE declaration extensions, refer to Extension to the Define Declaration.
When <text> contains one or more complete statements, consider bracketing it with a BEGIN/END pair. For example, the code
DEFINE SKIP_ONE = BEGIN PTR:=*+1; K:=*-1 END #
is safer than
DEFINE SKIP_ONE = PTR:=*+1; K:=*-1 #
because it accommodates invocations immediately following the reserved words DO, THEN, and ELSE.
When <text> is an expression but not a primary, consider making the expression a primary by enclosing it in parentheses. For example, the code
DEFINE SUM(A,B) = ((A) + (B)) #
is safer than
DEFINE SUM(A,B) = (A) + (B) #
because it accommodates invocations such as SUM(A,B)*3.

