88-Level and display.

OS/VS COBOL, COBOL II, Enterprise COBOL for z/OS. OpenCOBOL and OOCobol.
Post Reply
Sachin Kumar
Registered Member
Posts: 24
Joined: Wed Jul 17, 2013 9:08 am

88-Level and display.

Post by Sachin Kumar »

Hi,

Can we display the value of 88-level variables?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: 88-Level and display.

Post by Robert Sample »

1. There is no such thing as an 88-level variable.
2. 88 levels are called conditions, not variables.
3. You can display the variable associated with the 88-level, but not the condition.

Code like this (untested) would achieve what you asked:

Code: Select all

05  WS-VAR PIC X(01).
     88  COND-A VALUE 'A'.
     88  COND-B VALUE 'B'.

IF  COND-A
    DISPLAY 'COND-A ' WS-VAR
ELSE
     IF  COND-B
         DISPLAY 'COND-B' WS-VAR
     END-IF
END-IF.
Manoj
Registered Member
Posts: 33
Joined: Wed Jul 17, 2013 9:10 am

Re: 88-Level and display.

Post by Manoj »

Robert Sample wrote:1. There is no such thing as an 88-level variable.
So is it always wrong to mention them as "variables"?
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: 88-Level and display.

Post by Robert Sample »

An 88-level is not a variable. The manual calls them
88 Identifies any condition-name entry that is associated with a particular value of a conditional variable. (For details, see "VALUE clause" in topic 5.3.18.)
and the various places in the manual will refer to "condition-name" or "entry" for 88-levels.

If you refer to an 88-level as a variable, people will generally know what you mean; however, if you try something like MOVE 'A' TO COND-A in your program, you will find out that COBOL does NOT treat 88-levels as variables
Sachin Kumar
Registered Member
Posts: 24
Joined: Wed Jul 17, 2013 9:08 am

Re: 88-Level and display.

Post by Sachin Kumar »

That make sense Robert and I think a kind of notion one (I) can't figure out from manuals...Thanks for your time.
User avatar
Robert Sample
Global Moderator
Global Moderator
Posts: 1896
Joined: Fri Jun 28, 2013 1:22 am
Location: Dubuque Iowa
United States of America

Re: 88-Level and display.

Post by Robert Sample »

It is common -- but wrong -- to see them referred to as "variables". From the Enterprise COBOL Language Reference manual, the distinction is clarified:
A condition-name is used in conditions as an abbreviation for the relation condition. The rules for comparing a conditional variable with a condition-name value are the same as those specified for relation conditions. If condition-name-1 has been associated with a range of values (or with several ranges of values), the conditional variable is tested to determine whether its value falls within the ranges, including the end values. The result of the test is true if one of the values that corresponds to the condition-name equals the value of its associated conditional variable. | Condition-names are allowed for alphanumeric, DBCS, national, and | floating-point data items, as well as others, as defined for the | condition-name format of the VALUE clause. The following example illustrates the use of conditional variables and condition-names:

01 AGE-GROUP PIC 99.
88 INFANT VALUE 0.
88 BABY VALUE 1, 2.
88 CHILD VALUE 3 THRU 12.
88 TEENAGER VALUE 13 THRU 19.


AGE-GROUP is the conditional variable; INFANT, BABY, CHILD, and TEENAGER are condition-names. For individual records in the file, only one of the values specified in the condition-name entries can be present.
The variable is called the conditional variable while the associated 88-levels are condition names -- so it is NOT correct to refer to 88-levels as "variables".
William Collins
Global Moderator
Global Moderator
Posts: 490
Joined: Sun Aug 25, 2013 7:24 pm

Re: 88-Level and display.

Post by William Collins »

You can't directly DISPLAY the values associate with 88's (for the reasons Robert has gone into) but you can see them. In your source. In the compile listing. In the loadmodule on the library, as part of the module in a dump, etc. Why would you need more than that?
Sachin Kumar
Registered Member
Posts: 24
Joined: Wed Jul 17, 2013 9:08 am

Re: 88-Level and display.

Post by Sachin Kumar »

Got it, thanks.
Post Reply

Create an account or sign in to join the discussion

You need to be a member in order to post a reply

Create an account

Not a member? register to join our community
Members can start their own topics & subscribe to topics
It’s free and only takes a minute

Register

Sign in

Return to “IBM COBOL, GnuCOBOL (OpenCOBOL), OOCobol.”