Scope and variability of system variable symbols
- Global Scope
- Some system variable symbols have values that are established at the beginning of an assembly and are available both in open code and from within macros. These symbols have global scope. Most system variable symbols with global scope have fixed values, although there are some whose value can change within a single macro expansion. The global-scope system variables symbols with variable values are &SYSSTMT, &SYSM_HSEV, and &SYSM_SEV.
- Local Scope
- Some
system variable symbols have values that are available only from within
a macro expansion. These system variables have local scope. Since
the value of system variable symbols with local scope is established
at the beginning of a macro expansion and remains unchanged throughout
the expansion, they are designated as having constant values, even
though they might have different values in a later expansion of the
same macro, or within inner macros.
Over half of the system variable symbols have local scope and therefore are not available in open code.
Figure 1. Exposing the value of a local scope variable to open code 1 macro 2 getlocalsys 3 .* Define globals for values of interest 4 Gblc &clock,&location,&dsname,&nest 5 Gbla &nesta 6 .* now update the globals from within the macro 7 &clock setc '&sysclock' 8 &location setc '&sysloc' 9 &dsname setc '&sysin_dsn' 10 &nest setc '&sysnest' 11 &nesta seta &sysnest 12 mend 000000 00000 00020 14 r csect 15 * 16 * define globals in opencode 17 * 18 Gblc &clock,&location,&dsname,&nest 19 Gbla &nesta 20 * 21 * invoke macro to update the global values 22 * 23 getlocalsys 24 * 25 * now use the updated values 26 * 27 dc c'&clock' 000000 F2F0F0F460F0F660 + dc c'2008-07-11 17:48:42.914829' 28 dc c'&nest' 00001A F1 + dc c'1' 29 dc f'&nesta' 00001B 00 00001C 00000001 + dc f'1' 000000 31 end r
- Uses, values, and properties
- System variable symbols have many uses, including:
- Helping to control conditional assemblies
- Capturing environmental data for inclusion in the generated object code
- Providing program debugging data
Refer to Macro and conditional assembly language summary for a summary of the values and properties that can be assigned to system variable symbols.