typestar

Level 88 conditions in COBOL

Level 88 gives a data value a name you can test and SET like a flag.

IDENTIFICATION DIVISION.
PROGRAM-ID. CONDITION-NAMES.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 LOCK-STATE   PIC X VALUE "C".
   88 LOCK-OPEN    VALUE "O".
   88 LOCK-CLOSED  VALUE "C".
   88 LOCK-FAULTED VALUE "F" "X".
PROCEDURE DIVISION.
*> Level 88 names a condition; SET ... TO TRUE stores its value.
    IF LOCK-CLOSED DISPLAY "Canal gate sealed" END-IF
    SET LOCK-OPEN TO TRUE
    IF LOCK-OPEN DISPLAY "Gate open, tug may pass" END-IF
    STOP RUN.

How it works

  1. Three 88 entries name the states of LOCK-STATE; one lists two values.
  2. IF LOCK-CLOSED reads as prose but tests LOCK-STATE = "C".
  3. SET LOCK-OPEN TO TRUE stores the value that makes the condition hold.

Keywords and builtins used here

The run, in numbers

Lines
14
Characters to type
432
Tokens
56
Three-star pace
40 tpm

At the three-star pace of 40 tokens a minute, this run takes about 84 seconds.

Type this snippet

Step 3 of 3 in Conditions, step 15 of 27 in Language basics.

← Previous Next →