Figurative constants are reserved words that mean a fixed value: ZEROS, SPACES, HIGH-VALUE, LOW-VALUE, QUOTE, and ALL literal. When you use them with a data item, the compiler uses the right type and repeats the value to match the item’s length. They are handy for initializing, clearing, and comparing without hard‑coding lengths or character codes.
| Constant | Meaning |
|---|---|
| ZERO, ZEROS, ZEROES | Numeric zero or character zero(s); length from context |
| SPACE, SPACES | Space character(s); used to blank or clear alphanumeric fields |
| HIGH-VALUE, HIGH-VALUES | Highest character in collating sequence (e.g. X'FF'); sentinels |
| LOW-VALUE, LOW-VALUES | Lowest character in collating sequence (e.g. X'00') |
| QUOTE, QUOTES | Quotation mark character; e.g. to include quotes in a string |
| ALL literal | Repeats the literal to fill the receiving item (e.g. ALL "-") |
Singular and plural forms are equivalent: ZERO/ZEROS/ZEROES, SPACE/SPACES, HIGH-VALUE/HIGH-VALUES, LOW-VALUE/LOW-VALUES, QUOTE/QUOTES.
123456789101112131401 WS-NAME PIC X(30) VALUE SPACES. 01 WS-COUNT PIC 9(5) VALUE ZEROS. 01 WS-SENTINEL PIC X(10) VALUE HIGH-VALUE. *> Clear a field at runtime MOVE SPACES TO WS-NAME *> Initialize numeric to zero MOVE ZEROS TO WS-COUNT *> Compare to sentinel IF WS-KEY = HIGH-VALUE STOP RUN END-IF
VALUE SPACES gives WS-NAME 30 spaces. VALUE ZEROS gives WS-COUNT numeric zero. VALUE HIGH-VALUE fills WS-SENTINEL with the high-value character in each position. MOVE SPACES TO clears the receiving field to spaces regardless of its length.
QUOTE (or QUOTES) is the quotation-mark character. Use it when you need a quote inside a string delimited by quotes. ALL literal repeats the literal to fill the receiving item; e.g. MOVE ALL \"-\" TO WS-LINE fills WS-LINE with dashes. The literal can be one character or a short string; it is repeated until the receiving field is full.
Figurative constants are shortcut names for “all spaces,” “all zeros,” “the biggest character,” and so on. You say SPACES and the computer fills as many spaces as the box needs. You don’t have to count; the compiler does it.
1. Which figurative constant fills a field with blank characters?
2. Are ZERO and ZEROS equivalent in COBOL?