Created SET symbols

The assembler can create SET symbols during conditional assembly processing from other variable symbols and character strings. A SET symbol thus created has the form &(e), where e represents one or more of these:

  • Variable symbols, optionally subscripted
  • Strings of alphanumeric characters
  • Other created SET symbols

After substitution and concatenation, e must consist of a string of up to 62 alphanumeric characters, the first of which is alphabetic. The assembler considers the preceding ampersand and this string as the name of a SET variable. If this created SET symbol has the same name as an existing SET symbol, they are treated as identical. If this created SET symbol does not have the name of any existing SET symbol, the usual rules for assigning type and scope apply.

You can use created SET symbols wherever ordinary SET symbols are permitted, including declarations. You can also nest created SET symbols in other created SET symbols.

Consider the following example:
&ABC(1)  SETC            'MKT','27','$5'
Let &(e) equal &(&ABC(&I)QUA&I).
&I  &ABC(&I)  Created SET Symbol  Comment

1   MKT       &MKTQUA1            Valid
2   27        &27QUA2             Invalid: character after '&' not alphabetic
3   $5        &$5QUA3             Valid
4             &QUA4               Valid
A created SET symbol cannot be used to refer to a system variable symbol or a symbolic parameter in a macro definition, because the created SET symbol always refers to a SET symbol, even when the name is the same as a system variable symbol or symbolic parameter. You can define a created SET symbol with the same name as a system variable symbol, which will be used to resolve a normal symbol reference only if the system variable symbol is not available at the current assembler maintenance level. This effectively provides a default value for an unavailable system variable symbol, as in the following example:
&(SYS_HLASM_DATE) SETC '00000000' Default if not available
         AIF   ('&SYS_HLASM_DATE' LT '20181231').OLD

The created SET symbol can be thought of as a form of indirect addressing. With nested created SET symbols, you can perform this kind of indirect addressing to any level.

In another sense, created SET symbols offer an associative storage facility. For example, a symbol table of numeric attributes can be referred to by an expression of the form &(&SYM)(&I) to yield the Ith attribute of the symbol name in &SYM. As this example indicates, created SET symbols can be declared and used as arrays of dimensioned variables.

Created SET symbols also enable you to achieve some of the effect of multiple-dimensioned arrays by creating a separate name for each element of the array. For example, a 3-dimensional array of the form &X(&I,&J,&K) might be addressed as &(X&I.$&J.$&K), where &I, &J, and &K typically have numeric values. Thus, &X(2,3,4) is represented by &X2$3$4. The $ separators guarantee that &X(2,33,55) and &X(23,35,5) are unique:
&X(2,33,55) becomes &X2$33$55
&X(23,35,5) becomes &X23$35$5