Boolean data

5.3 Boolean Data

Boolean data is either TRUE or FALSE. These are data types are useful for flags for so-called condition-name conditions (see Commands and Logic section).

A simple example:

  • When then number entered (line 250) is greater than 1000 then a 'Y' character is moved to the level 01 item NUMBER-SIZE. The effect of this is to give the level 88 item BIG-NUMBER a TRUE condition. This is what level 88 is for in COBOL.
  • Line 240 initially sets BIG-NUMBER to false by moving an 'N' character into NUMBER-SIZE, although any character (other than 'Y') would have the same effect.
  • IF BIG-NUMBER THEN... is like saying "IF BIG-NUMBER is true THEN..."

Multiple level 88 can be set for a single group, or you can have more than one option that will set the condition to true.


01 THIRTY-DAY-MONTHS PIC X VALUE SPACE. 88 SEPTEMBER VALUE 'S'. 88 APRIL VALUE 'A'. 88 JUNE VALUE 'J'. 88 NOVEMBER VALUE 'N'. 01 MONTHS-CHECK PIC X. 88 SHORT-MONTH VALUE 'S' 'A' 'J' 'N' 'F'. 01 GRADES-CHECK PIC 999. 88 A-GRADE VALUE 70 THRU 100. 88 B-GRADE VALUE 60 THRU 69. 88 C-GRADE VALUE 50 THRU 59. 88 FAIL-GRADE VALUE 0 THRU 49.

GRADES-CHECK uses THRU (or THROUGH) to allow a range of numeric values to be tested.  

   SET

A useful verb to use is SET. Rather than having to use the line:
    MOVE 'Y' TO NUMBER-SIZE
as in the code example above, you can simply set the boolean variable to true by coding:
    SET BIG-NUMBER TO TRUE
This means that you don't have to worry about what the value of the level 01 item has to be in order to make the associated level 88 to be true (notice that it is the level 88 item name that is set to true and NOT the level 01 item). Of course, you might also code
    SET BIG-NUMBER TO FALSE.