SETC variables in arithmetic expressions

The assembler permits a SETC variable to be used as a term in an arithmetic expression if the character string value of the variable is a self-defining term or a predefined absolute symbol. The value represented by the string is assigned to the arithmetic term. A null string is treated as zero.

Examples:
         LCLC            &C(5)
&C(1)    SETC            'B''101'''
&C(2)    SETC            'C''A'''
&C(3)    SETC            '23'
&A       SETA            &C(1)+&C(2)-&C(3)

In evaluating the arithmetic expression in the fifth statement, the first term, &C(1), is assigned the binary value 101 (decimal 5). To that is added the value represented by the EBCDIC character A (hexadecimal C1, which corresponds to decimal 193). Then the value represented by the third term &C(3) is subtracted, and the value of &A becomes 5+193-23=175.

This feature lets you associate numeric values with EBCDIC or hexadecimal characters to be used in such applications as indexing, code conversion, translation, and sorting.

Assume that &X is a character string with the value ABC.
&I       SETC            'C'''.'&X'(1,1).''''
&VAL     SETA            &TRANS(&I)

The first statement sets &I to C'A'. The second statement extracts the 193rd element of &TRANS (C'A' = X'C1' = 193).

The following code converts a hexadecimal value in &H into a decimal value in &VAL:
&X       SETC            'X''&H'''
&VAL     SETA            &X
The following code converts the double-byte character Da into a decimal value in &VAL. &VAL can then be used to find an alternative code in a subscripted SETC variable:
&DA      SETC            'G''<Da>'''
&VAL     SETA            &DA
Instead of using a predefined absolute symbol as an operand in a SETA expression, you can substitute a SETC or parameter variable whose value is the same as the name of the symbol. For example:
ABS     EQU    5
&ABS    SETA   ABS           &ABS has value 5
&CABS   SETC   'ABS'         &CABS has value 'ABS'
&ABS    SETA   &CABS         &ABS has value 5