Level 88

10 ERROR-FLAG PIC X VALUE 'N'. 88 ERROR-FOUND VALUE 'Y'. 88 ERROR-NOT-FOUND VALUE 'N'. 

If I do this:

 SET ERROR-NOT-FOUND TO TRUE 

Then I do:

 SET ERROR-FOUND TO TRUE 

Now what will be the values ​​of ERROR-FLAG, ERROR-FOUND and ERROR-NOT-FOUND?

+5
source share
1 answer
 10 ERROR-FLAG PIC X VALUE 'N'. 88 ERROR-FOUND VALUE 'Y'. 88 ERROR-NOT-FOUND VALUE 'N'. 

A 10-level number defines one byte of memory as alphanumeric, which means without a hint of a problem, it can contain any bit value from X'00 'to X'FF'.

Two 88 levels do not define storage.

Typically, 88 is a way to give a name to literal (or multiple) letters, but only associate it with the specific field that it refers to (ERROR-FLAG in this case).

Here, ERROR-FLAG is a "conditional variable" (which means that it has one or more 88 levels associated with it), and each of the 88s is a "condition-name".

If you do this:

 SET ERROR-NOT-FOUND TO TRUE 

Then

 IF ERROR-NOT-FOUND 

Will be true and

 IF ERROR-FOUND 

It will not be true.

The setting is the same as:

 MOVE "N" TO ERROR-FLAG 

And IF matches:

 IF ERROR-FLAG EQUAL TO "N" *> for the IF ERROR-NOT-FOUND 

The advantages of 88 and SET for changing the value of the field to which it relates are documentary and reduce maintenance.

Remember that the name condition does not define the repository (strictly, the repository is associated with it, but it just contains a literal, and you cannot get it).

So SET ERROR-NOT-FOUND TO TRUE (good interval, very good) does nothing for ERROR-NOT-FOUND (nothing can be done), but puts the value "N" in ERROR-FLAG.

So SET ERROR-FOUND TO TRUE does nothing for ERROR-FOUND, but puts the value "Y" in ERROR-FLAG.

Encoding both of these SET statements in a sequence simply ends up with ERROR-FLAG being "Y" (the first SET will be redundant).

The SET statement for level 88 generates code identical to the MOVE statement (or should / could, doesn't know about all compilers). You use SET so that you cannot accidentally spoil the flag value through a typo (or through incompetence).

Best structure for flags / radio buttons:

 01 FILLER. 10 FILLER PIC X. 88 ERROR-FOUND VALUE 'Y'. 88 ERROR-NOT-FOUND VALUE 'N'. 10 FILLER PIC X. 88 AMOUNT-NUMERIC VALUE 'Y'. 88 AMOUNT-NOT-NUMERIC VALUE 'N'. 

When you specify a conditional variable name, as it was in your example, someone can encode MOVE to reference it, and seal the value, or make code analysis more complicated. Using FILLER to define fields that cannot be referenced from the PROCEDURE DIVISION section prevents this. Certain data can only be accessed via SET and IF (for polling a value).

The code will have:

 SET ERROR-NOT-FOUND AMOUNT-NOT-NUMERIC TO TRUE 

To start each iteration of processing (it’s best not to rely on VALUE, since you have to reinstall it every time anyway), and then separate SET instructions when specific symptoms that require a flag are identified.

No, 88 can have several meanings. VALUE "A" "Q" "V" THRU "Z", for example. When executing SET, the value specified above in the VALUE statement is used, "A" in this example.

See this answer with a number of links to other answers: fooobar.com/questions/1216385 / ...

+8
source

Source: https://habr.com/ru/post/1216383/


All Articles