# Figurative Constants

Figurative constants are system-defined constants with predefined values. These figurative constants are known to the COBOL language and replaced with predefined values when coded.

The figurative constants in COBOL are -

• ZERO, ZEROS, ZEROES
• SPACE, SPACES
• HIGH-VALUE, HIGH-VALUES
• LOW-VALUE, LOW-VALUES
• QUOTE, QUOTES
• ALL
• symbolic-character

## ZERO, ZEROS, ZEROES -

ZERO is the figurative constant that represents the numeric value 0. The ZERO has three forms: ZERO, ZEROS or ZEROES. i.e., ZERO means a single 0 and ZEROS or ZEROES means two or more occurrences of 0's. These constants are used to initialize numeric or alphanumeric variables with 0.

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTZ     PIC 9(10) VALUE ZEROES.``

Initializing variable in procedure division -

`` MOVE ZEROES TO WS-FIGCONSTZ.``

Using for comparison -

`````` IF WS-FIGCONSTZ EQUAL ZEROES
......
END-IF.``````

## SPACE, SPACES -

SPACE is a figurative constant that represents " " or X'40'. SPACE has two forms: SPACE or SPACES. i.e., SPACE means single SPACE (" "), and SPACES means two or more occurrences of space. These constants are used to initialize alphabetic or alphanumeric variables with space.

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTS    PIC X(10) VALUE SPACES.``

Initializing variable in procedure division -

`` MOVE SPACES TO WS-FIGCONSTS.``

Using for comparison -

`````` IF WS-FIGCONSTS EQUAL SPACES
......
END-IF.``````

## HIGH-VALUE, HIGH-VALUES -

HIGH-VALUE is a figurative constant that represents the X'FF' (8-bit character code for all binary 1s). The HIGH-VALUE has two forms: HIGH-VALUE and HIGH-VALUES. i.e., HIGH-VALUE means a single X'FF', and HIGH-VALUES means two or more X'FF' occurrences. These constants are used to initialize alphanumeric variables with X'FF'.

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTH    PIC X(10) VALUE HIGH-VALUES.``

Initializing variable in procedure division -

`` MOVE HIGH-VALUES TO WS-FIGCONSTH.``

Using for comparison -

`````` IF WS-FIGCONSTH EQUAL HIGH-VALUES
......
END-IF.``````

## LOW-VALUE, LOW-VALUES -

LOW-VALUE is a figurative constant that represents the X'00' (8-bit character code for all binary 0s). The LOW-VALUE has two forms: LOW-VALUE or LOW-VALUES. LOW-VALUE means single X'00', and LOW-VALUES means two or more X'00' occurrences. These constants are used to initialize alphanumeric variables with X'00'.

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTL     PIC X(10) VALUE LOW-VALUES.``

Initializing variable in procedure division -

`` MOVE LOW-VALUES TO WS-FIGCONSTL.``

Using for comparison -

`````` IF WS-FIGCONSTL EQUAL LOW-VALUES
......
END-IF.``````

## QUOTE, QUOTES -

QUOTE is a figurative constant that represents one or more occurrences of -

• The quotation mark character ("), if the QUOTE compiler option is in effect.
• The apostrophe character (') if the APOST compiler option is in effect.

The QUOTE has two forms: QUOTE or QUOTES. These two different forms represent the multiple forms of quotation(") or apostrophe ('). i.e., QUOTE means single quote, QUOTES means two or more quote occurrences. These constants are used to initialize alphanumeric variables with quotation(") or apostrophe (').

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTQ    PIC X(10) VALUE QUOTES.``

Initializing variable in procedure division -

`` MOVE QUOTES TO WS-FIGCONSTQ.``

Using for comparison -

`````` IF WS-FIGCONSTQ EQUAL QUOTES
......
END-IF.``````

## ALL -

• ALL literal represents one or more occurrences of the characters-string that form the literal.
• ALL can use as a literal and figurative constant.
• ALL will not code alone and should be followed by other figurative constants, user-defined literals, or character strings.
• ALL should not be used with the CALL, INSPECT, INVOKE, STOP or STRING statements.

For example -

Initializing variable during declaration -

`` 01 WS-FIGCONSTS         PIC X(10).``

Initializing variable in procedure division -

`` MOVE ALL SPACES TO WS-FIGCONSTS.``

Using with INSPECT -

`` INSPECT WS-FIGCONSTS TALLYING WS-COUNT FOR ALL " ".``

## Symbolic character -

• The symbolic character represents one or more characters specified as a value in the SYMBOLIC CHARACTERS clause of the SPECIAL-NAMES paragraph.
• The SYMBOLIC CHARACTERS clause assigns symbolic names to any character of the specified alphabet.
• A symbolic character always represents an alphanumeric character.

For example - Reassign "cancel" to 27.

``````     ENVIRONMENT DIVISION.
CONFIGURATION SECTION.
SPECIAL-NAMES.
SYMBOLIC CHARACTERS CANCEL IS 27.
``````