$DEFINE Directive

The $DEFINE preprocessor directive associates a string of text with a macro name. When the preprocessor encounters a defined macro name in the source program, it invokes the macro and passes the associated string of text.

The string of text may specify up to nine formal parameters. If the string of text uses parameters, then the macro call can specify actuals for these parameters; otherwise, they are ignored.


$DEFINE macro-name=[string-text]#


macro-name is the name of the macro. Macro names begin with a non-alphanumeric character. By default, it is the percent symbol ("%");

string-text is a string of text to replace occurrences of the macro call within the body of the program code. The string of text may contain formal parameters (which are sometimes referred to as variables). These are designated by an exclamation point followed by an integer in the range of 1 to 9. string-text may also contain other macro calls, which recursively expand; and

string-text is delimited by the equal sign ("=") and pound sign ("#"). The pound sign marks the end of the definition. The pound sign is the default delimiter and it can be changed with the $PREPROCESSOR command.

Note: Use of an "&" character is interpreted as part of the macro definition and not as a continuation (as it would in the $COMMENT command).

If the string-text starts on the same line as the macro name, the replacing text is expanded from exactly the same column as the macro call. Otherwise, the replacing text starts at the beginning of the next line.

The two different forms of the macro call are:





"p1", "p2", ..., "pn" are actual parameters that replace the formal parameters in the string of text. Each actual parameter can be a null character or any combination of characters, including spaces;

n is an integer in the range of 1 to 9; and

"#" is a delimiter.

Formal parameters that are not specified with an actual parameter in the macro call are ignored. You can specify which formal parameters should be ignored by entering only a pound sign ("#") in the appropriate position within the macro call. For example, to ignore the first parameter, you write the call like this: