88 Levels
Part of the Decisions and Loops section of Coddy's COBOL Programming journey. Lesson 6 of 20.
A condition name names a value of a field. It is written at level 88 under the field:
01 ACCT-STATUS PIC X.
88 IS-OPEN VALUE "O".
88 IS-CLOSED VALUE "C".The name is a condition, so an IF tests it directly. IF IS-OPEN means IF ACCT-STATUS = "O":
IF IS-OPEN
DISPLAY "Payments allowed"
END-IF.One condition name can cover several values, or a range with THRU:
88 IS-VOWEL VALUE "A" "E" "I" "O" "U".
88 IS-TEEN VALUE 13 THRU 19.A condition name holds no data of its own. When a code changes, only its 88 line changes, and every IF that uses the name stays the same. NOT IS-OPEN works like any other condition.
Challenge
EasyAdd a condition name IS-OPEN for the value O under ACCT-STATUS. Then print Payments allowed when the account is open and Payments blocked otherwise.
Example input, one line per ACCEPT: O.
Try it yourself
IDENTIFICATION DIVISION.
PROGRAM-ID. ACCTST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 ACCT-STATUS PIC X.
*> Add IS-OPEN here
PROCEDURE DIVISION.
ACCEPT ACCT-STATUS.
*> Print Payments allowed or Payments blocked
STOP RUN.