Is an 88 level initialised when being set to true?



Support for OS/VS COBOL, VS COBOL II, COBOL for OS/390 & VM and Enterprise COBOL for z/OS

Is an 88 level initialised when being set to true?

Postby DSP_London » Tue Mar 05, 2013 3:38 pm

Hello,

Haven't done any coding for about 8 years, so I'm rather rusty! Just have a quick question about 88 levels, and I haven't been able to find a definitive answer in the manuals (although that may be down to my poor manual-trawling skills, rather then the information not being there!).

If I have a field with a couple of associated 88 levels thus:

04 ACTION-TYPE PIC X(6)
88 UPD VALUE 'UPDATE'
88 NEW VALUE 'NEW'

(I know that in this particular example I could use a PIC X and have 'U' and 'N' as values, but that doesn't work for my particular problem, nor would it particularly clear to someone reading it.)

If I code:

SET UPD TO TRUE

Then ACTION-TYPE contains 'UPDATE'

If later on, the code then goes though:

SET NEW TO TRUE

Does ACTION-TYPE get initialised first? I'd want ACTION-TYPE to contain 'NEW ', but I'm not 100% sure that it wouldn't contain 'NEWATE'.

If someone could confirm or deny it, I'd be grateful!

You know what? I could just write something and try it!
/slaps head

If anyone's got an answer, I'd appreciate it, particularly if there are 'exceptions to the rule', but meanwhile I'll go and knock something up.

Cheers!

DSP
DSP_London
 
Posts: 3
Joined: Tue Mar 05, 2013 3:25 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Is an 88 level initialised when being set to true?

 

Re: Is an 88 level initialised when being set to true?

Postby DSP_London » Tue Mar 05, 2013 3:49 pm

Turns out the field gets cleared, so in the above example, I end up with 'NEW', not 'NEWATE'.

You live and learn!

DSP
DSP_London
 
Posts: 3
Joined: Tue Mar 05, 2013 3:25 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Is an 88 level initialised when being set to true?

Postby BillyBoyo » Tue Mar 05, 2013 4:48 pm

Sometimes while describing your problem, you get to the answer or a way to get to the answer. We don't mind that at all.

Since the "NEW" test on the 88 had to operate when the field contained only "NEWbbb" (where b=blank) and not "NEWany" (where any is anything), then you'd expect the field to initialise to "NEWbbb", which you showed.

EDIT:

I just notice that you think it is first cleared to space then set to "NEW". To emphasise the above, the length of all the 88s for that field are six bytes, automatically space-padded when the value is shorter than six characters.

These users thanked the author BillyBoyo for the post:
DSP_London (Wed Mar 06, 2013 3:51 am)
BillyBoyo
Global moderator
 
Posts: 3804
Joined: Tue Jan 25, 2011 12:02 am
Has thanked: 22 times
Been thanked: 264 times

Re: Is an 88 level initialised when being set to true?

Postby DSP_London » Tue Mar 05, 2013 7:05 pm

"the length of all the 88s for that field are six bytes, automatically space-padded when the value is shorter than six characters."

Ah! That's the bit I wasn't sure about.

Thanks for the clarification.

DSP
DSP_London
 
Posts: 3
Joined: Tue Mar 05, 2013 3:25 pm
Has thanked: 2 times
Been thanked: 0 time

Re: Is an 88 level initialised when being set to true?

Postby Robert Sample » Tue Mar 05, 2013 9:19 pm

There is a basic misunderstanding in the title of your post that needs to be cleared up as well. An 88 level CANNOT be initialized as it is not a variable -- which the COBOL Language Reference manual tells you -- as it is a called a conditional and has no strorage allocated to it. The associated conditional variable has storage allocated for it, but the conditional itself is merely a value or set of values (per 5.3.3 of the manual).

These users thanked the author Robert Sample for the post:
DSP_London (Wed Mar 06, 2013 3:51 am)
Robert Sample
Global moderator
 
Posts: 3367
Joined: Sat Dec 19, 2009 8:32 pm
Location: East Dubuque, Illinois
Has thanked: 1 time
Been thanked: 222 times

Re: Is an 88 level initialised when being set to true?

Postby Ed Goodman » Wed Mar 06, 2013 8:39 pm

Not knowing assembler, I would have turned that question around: Would 'NEWATE' resolve as TRUE for 'IF NEW'?

Since the answer is no, I would have guessed the final result to be 'NEW '.
Ed Goodman
 
Posts: 342
Joined: Thu Feb 24, 2011 12:05 am
Has thanked: 3 times
Been thanked: 17 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post