What does this piece of code mean?



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

What does this piece of code mean?

Postby uday123 » Wed Mar 25, 2009 4:03 am

This is a piece from original code..

IF MRE-LICENSE-STATUS(6:) = 'ACTIVE'

Does this mean that if data of length 6 bytes in MRE-LICENSE-STATUS is 'ACTIVE' then do something..

(or)

Data starting from 6th position in MRE-LICENSE-STATUS is ACTIVE then do something..?

Please advice. Thanx

Uday
uday123
 
Posts: 29
Joined: Fri Feb 06, 2009 6:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: What does this piece of code mean?

 

Re: What does this piece of code mean?

Postby dick scherrer » Wed Mar 25, 2009 4:20 am

Hello,

This code uses Reference Modification.

IF MRE-LICENSE-STATUS(6:)
To the left of the ":" defines the left-most character position. To the right is the length.

Data starting from 6th position in MRE-LICENSE-STATUS is ACTIVE then do something.

For complete info, look here:
http://publibz.boulder.ibm.com/cgi-bin/ ... 0/1.8.1.10?
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: What does this piece of code mean?

Postby uday123 » Wed Mar 25, 2009 4:38 am

SO what does this mean?

IF (MRE-LICENSE-STATUS = SPACES OR 'ACTIVE' OR
'IN FORCE' OR 'CLEAR' OR
'ELIGIBLE' OR 'LICENSED' OR
'CURRENT' OR 'SUSP INS TERMINATED')
OR
(MRE-LICENSE-STATUS(1:6) = 'VALID ')
OR
(MRE-LICENSE-STATUS(1:16) = 'TEMPORARY PERMIT')
OR
(MRE-LICENSE-STATUS(1:4) = 'CDL:')
OR
(MRE-LICENSE-STATUS(1:4) = 'PDL:'
AND
(MRE-LICENSE-STATUS(6:) = 'ACTIVE' OR 'VALID' OR
'IN FORCE' OR 'CLEAR'))

CONTINUE

ELSE
SET INSERT-DLR-ATTRIBUTE TO TRUE


Does this mean that ..Go to else condition if MRE-LICENSE-STATUS is not any one of these ? ( ACTIVE , VALID , IN FORCE, CLEAR ) .. I mean any one of the OR criteria and the AND criteria in IF condition should match for the loop to CONTINUE..?
is it so?

wat happens if the AND condition in IF is not satisfied.. but only OR is satisfied?? where does the loop go?

Uday
uday123
 
Posts: 29
Joined: Fri Feb 06, 2009 6:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: What does this piece of code mean?

Postby dick scherrer » Wed Mar 25, 2009 6:56 am

Hello,

where does the loop go?
I see no loop in this code. . :?

Go to else condition if MRE-LICENSE-STATUS is not any one of these
If none of the conditions are met, the ELSE is executed. You need to pay attention to the parentheses.

I suspect the first "test" may not work for all cases.

Suggest you take this bit of code and isolate it into a separate module and very thoroughly test it for all conditons. Your input for testing can be data in a DD * dataset to easily create test data for all cases.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: What does this piece of code mean?

Postby uday123 » Wed Mar 25, 2009 3:42 pm

ok, i will rather put it this way..
where does the control go???

if there is an OR and AND in IF condition, for the IF condition to be true , any one of the OR criteria and all of the criteria's in AND need to be true..else IF
conditon will be a false..and go to else..am i right?

Thanx
uday
uday123
 
Posts: 29
Joined: Fri Feb 06, 2009 6:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: What does this piece of code mean?

Postby dick scherrer » Thu Mar 26, 2009 12:15 am

Hello,

To repeat. . .
Suggest you take this bit of code and isolate it into a separate module and very thoroughly test it for all conditons. Your input for testing can be data in a DD * dataset to easily create test data for all cases.
If you perform the proper testing, you will learn what you want to know.

where does the control go???
Also repeating:
If none of the conditions are met, the ELSE is executed. You need to pay attention to the parentheses.

Once you have run a proper set of tests, all of the questions should be answered. If any are not, post the test data that caused an unexpected result and the question about it.
Hope this helps,
d.sch.
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times

Re: What does this piece of code mean?

Postby uday123 » Thu Mar 26, 2009 5:49 am

Thanks Scherrer.. Really worked out looking at the parenthesis.. Previously i did not pay much attention to that. :)

Regards
Uday
uday123
 
Posts: 29
Joined: Fri Feb 06, 2009 6:13 am
Has thanked: 0 time
Been thanked: 0 time

Re: What does this piece of code mean?

Postby dick scherrer » Thu Mar 26, 2009 6:20 am

You're welcome - good luck :)

d
User avatar
dick scherrer
Global moderator
 
Posts: 6304
Joined: Sat Jun 09, 2007 8:58 am
Has thanked: 3 times
Been thanked: 91 times


Return to IBM Cobol

 


  • Related topics
    Replies
    Views
    Last post