05 nicely-named-data PIC X. 88 a-meangingful-condition VALUE "A". 88 another-meaingingful-condition VALUE "A" "B" "X" THRU "Z" SPACE ZERO. IF a-meaningful-condition IF another-meaningful-condition SET a-meaningful-condition TO TRUE SET another-meaningful-condition TO TRUE
IFs check the value referenced by name-name (conditional variable) that 88 (condition name) is associated with for a single value or one of several values, which may include ranges (THRU) and figurative constants (ZERO, SPACE, LOW- VALUES etc.).
SET, which in this form is a later addition to COBOL from the 1985 Standard, will change the data-name value to the first value indicated at 88, so if you immediately refer to 88 in the test, the test will be true.
COBOL has no logical meanings in the sense of something allowing 0 or 1 or something else, false / true.
Any language that supports objects can be used to simulate behavior. You may have already done this without even realizing it.
As NealB notes in the comments, functions can be used (either a procedure or transferring control to another module), but the data and links to it will not be together and protected from accidental harm.
COBOL has great flexibility in defining data structures. The 88 level is a powerful tool for supporting and understanding programs, as well as writing them first.
I do not know another language that has a direct and natural element that is equivalent to this, but then there are many languages โโthat I do not know.
Again, NealB makes an important point in the comments about using THRU / THROUGH to specify a range of values.
Care must be taken. Although the author might think that the data they want to select may be represented by the range โ010โ THRU โ090โ, they may not understand that what the compiler does is to include every possible value in this range, generating code greater than or equal to "010" and less than or equal to "090".
If you use THRU, make sure your data cannot contain anything in the range that is not expected. If you mean "010" "020" "030" ... "090", it is normal if the data is checked at its entry point so that it never includes any intermediate values.
Classic example: "A" THRU "Z" on the mainframe. We all know what the author means, but the compiler takes it literally. You cannot use "A" THRU "Z" on your own for verification, because in EBCDIC there are "gaps" between three groups of letters, and using "A" THRU "Z" will consider these spaces as true for 88.
When level 88 in some COBOL compilers falls, it is in the absence of "FALSE".
For reuse from the above example:
88 a-meaingingful-condition VALUE "A". 88 a-meaingingful-condition-NOT VALUE "N".
To check the switch / flag, you use the first 88. To disable flag.switch, you must use the second. Not perfect. See One of the links below for an example of FALSE in definition 88.
In the old days, flags / switches and reset were set with MOVE statements. Once MOVE is activated, you have the same problems as when you try to use the functions. There is no related relationship between MOVE and VALUE level 88.
These days, SET can be used to change the value of a field, to turn on / off a flag / switch.
05 FILLER PIC X. 88 a-meaingingful-condition VALUE "A". 88 a-meaingingful-condition-NOT VALUE "N".
The test field does not even need a name (it can be FILLER or omitted (implied FILLER)).
Of course, as NealB notes in a comment on one of the links below, someone can still get the field using MOVE, using the modification link for the group element. So that...
01 FILLER. 05 FILLER PIC X. 88 a-meaingingful-condition VALUE "A". 88 a-meaingingful-condition-NOT VALUE "N".
Now they cannot use the standard link modification, since there is no name for the name. A field value can only be obtained from the VALUE clause in the definition or from a SET statement that sets one of 88s to TRUE.
At the stage, the value that the flag / switch has, its actual value, becomes irrelevant.
01 FILLER. 05 FILLER PIC X(7). 88 a-meaingingful-condition VALUE "APPLE". 88 a-meaingingful-condition-NOT VALUE "BICYCLE".
Since nothing can be used to check for literal / name-name, and the field cannot be the object of any verb other than SET, you no longer need to check that all fields that say they contain N or Y, or 0 or 1, do this, and they are not the wrong case, and no other values โโwill be placed in these fields.
I do not suggest using APPLE and BICYCLE, just using them to illustrate the point.
88 can also have a value expressed in hexadecimal notation, like any alpha-numeric field:
88 a-meaingingful-condition VALUE X"25".
Sign 88 may also be indicated in a group element, usually with a figurative constant as the value:
01 a-group-item. 88 no-more-data-for-matching VALUE HIGH-VALUES. 05 major-key PIC X(10). 05 minor-key PIC X(5).
In the process of matching files, the keys can be set to high values โโat the end of the file, and using the keys will still lead to the correct processing of other files (the keys are lower than this file).
Here are links to a number of SO questions directly or related to important issues, up to 88 levels.
Level Data Type 88 COBOL
Group variable in cobol
In Cobol, we use "NOT = SPACE [AND / OR] LOW-VALUE") to check for "null or empty".? What is it?
Does the prefix "NO" have any special meaning in the COBOL variable?
Verifying COBOL data for an uppercase letter?