1

I am looking at a piece of COBOL code which contains the following line:

SET NO-FURTHER-PROCESSING-REQD TO TRUE

It also contains the following lines:

IF  FURTHER-PROCESSING-REQD
...
END-IF.

Is there some magic going on whereby the variable without the "NO-" prefix is automatically set to the opposite of the variable with the prefix? Or is this more likely to be an oversight by the programmer?

jl6
  • 6,110
  • 7
  • 35
  • 65

1 Answers1

9

No.

If you look in the DATA DIVISION you'll find two 88-levels beneath the same data-item.

01  A-FLAG PIC X.
    88  FURTHER-PROCESSING VALUE "Y".
    88  NO-FURTHER-PROCESSING VALUE "N".

An 88 allows you to test the value of a field with a name, rather than just a literal.

In most COBOLs you can't, yet, SET an 88 to FALSE. So what is generally done, if using SET, is to make a second 88 which has an "opposite meaning" name and has a value which is different from the 88 you are using for your positive test.

So:

IF FURTHER-PROCESSING
    do something
    SET NO-FURTHER-PROCESSING TO TRUE
END-IF

Now, FURTHER-PROCESSING is not true after the set.

The name you give to the second 88 is not important for how it works (but important for the human reader). What is important is that the VALUE that it has is different from the value for the "truth" value of the 88 you are using.

Bill Woodger
  • 12,968
  • 4
  • 38
  • 47