$SET Statement

The $SET statement can be used to define compiler directives for use in IF Statement. The directives set with this method have no value, they are only set. The $SET statement can also be used to set values for COBOL variables in the same way as a level 78 data item.

There are two formats for the $SET statement.

Format 1

$SET [NO]compiler-directive

Format 2

$SET CONSTANT identifier value

Syntax

  1. The whole statement must appear on a single line.

General Rules

Format 1

  1. The sole effect of the Format 1 $SET statement is to set a directive name in the compilation unit. Alternatively, you can use the -/ (forward slash) compiler option to set a directive name. If a later Format 3 $IF statement is encountered, this statement will evaluate true if the compiler-directive set by $SET matches the directive-setting in the $IF statement. Preceding the compiler directive with NO turns off the setting. See Conditional Compilation Options in the ACUCOBOL-GT User’s Guidefor more information.

Format 2

  1. identifier must be a valid COBOL identifier.
  2. value is any valid value for a COBOL identifier.
  3. If value is surrounded by single (') or double (") quotes, it is a string literal. identifier can be used anywhere a string literal can be used.

  4. If value is surrounded by parentheses (()), it is a numeric literal.
  5. identifier can be used anywhere a numeric literal can be used.
  6. If value is neither quoted nor surrounded by parentheses, it will be

    considered a numeric literal if all of the characters in the value are digits. Otherwise it is considered a string literal.

  7. A format 2 $SET statement is equivalent to the following line:
    77 identifier VALUE value.

    with the exception that the level "77" line doesn't allow numeric values to be surrounded with parentheses.