在COBOL变量中有什么特殊含义

在COBOL变量中有什么特殊含义

本文介绍了前缀是否为“ NO”在COBOL变量中有什么特殊含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在查看一段包含以下行的COBOL代码:

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

SET NO-FURTHER-PROCESSING-REQD TO TRUE

它还包含以下几行:

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

是否发生了一些不可思议的事情,没有 NO-前缀的变量会自动设置为与变量相反的前缀?还是更有可能是程序员的疏忽?

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?

推荐答案

否。

如果您在DATA DIVISION中查看,则会在同一数据项下找到两个88级。

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".

88允许您使用名称而不是文字来测试字段的值。

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

在大多数COBOL中,您还无法将88设置为FALSE。因此,如果使用SET,通常要做的是制作第二个88,该名称具有相反的含义名称,并且其值不同于您用于阳性测试的88。

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.

因此:

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

现在,后续处理不成立

第二个88的名称对它的工作方式并不重要(但对人类读者而言很重要)。重要的是该值与您使用的88个值的真实值不同。

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.

这篇关于前缀是否为“ NO”在COBOL变量中有什么特殊含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 13:37