Multiple factors control whether macro calls are expanded in different
situations. At the highest level, SET MEXPAND
controls whether
macro calls are expanded. By default, it is enabled. See SET MEXPAND, for details.
A macro body may contain macro calls. By default, these are expanded.
If a macro body contains !OFFEXPAND
or !ONEXPAND
directives, then !OFFEXPAND
disables expansion of macro calls
until the following !ONEXPAND
.
A macro argument’s value may contain a macro call. These macro calls
are expanded, unless the argument was declared with the
!NOEXPAND
keyword.
The argument to a macro function is a special context that does not
expand macro calls. For example, if !vars
is the name of a
macro, then !LENGTH(!vars)
expands to 5, as does
!LENGTH(!1)
if positional argument 1 has value !vars
.
To expand macros in these cases, use the !EVAL
macro function,
e.g. !LENGTH(!EVAL(!vars))
or !LENGTH(!EVAL(!1))
.
See Macro Functions, for details.
These rules apply to macro calls, not to uses within a macro body of
macro functions, macro arguments, and macro variables created by
!DO
or !LET
, which are always expanded.
SET MEXPAND
may appear within the body of a macro, but it will
not affect expansion of the macro that it appears in. Use
!OFFEXPAND
and !ONEXPAND
instead.