Does a prefix of “NO” have any special meaning in a COBOL variable?

天大地大妈咪最大 提交于 2019-12-13 02:05:38

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/18721739/does-a-prefix-of-no-have-any-special-meaning-in-a-cobol-variable

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!