Macro Notes

The scope of a symbol is the area in which it may be declared.  Global scope is the entire assembly.  The distinct local scopes are the interiors of the macro expansions within an assembly.  Open code is not a local scope.  Therefore, a symbol having local scope may be declared only within macro expansions.

The value of a system variable symbol is set at the beginning of its scope and almost every system variable symbol is read-only, that is, its value remains constant throughout its scope.  Therefore, a system variable symbol having local scope, such as &SYSNDX or &SYSNEST, will almost always maintain a different constant value throughout each separate macro expansion.  Because this value is constant for all of the symbol’s references within an outer macro expansion, an inner macro expansion containing references to the same symbol does not affect the references in the outer macro that follow the inner macro call.

Note that the three system variable symbols that are not read-only: &SYSSTMT, &SYSM_HSEV, and &SYSM_SEV have global scope.

&SYSNDX maintains a counter that is incremented by each macro call and then assigned as the constant value of all references within the macro expansion.  In references within an inner macro expansion, the value of &SYSNDX will be greater by 1 than it is in references within the enclosing outer macro, including the ones directly following the inner macro call.

&SYSNEST maintains a counter that is incremented upon entry to and decremented upon exit from each macro.  &SYSNEST would have the same value within each of consecutive macro expansions, whereas &SYSNDX would have incremented values.


Copyright © 2006 The Stevens Computing Services Company, Inc.  All rights reserved.