Page 1 of 1

What does this piece of code mean?

PostPosted: Wed Mar 25, 2009 4:03 am
by uday123
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

Re: What does this piece of code mean?

PostPosted: Wed Mar 25, 2009 4:20 am
by dick scherrer
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?

Re: What does this piece of code mean?

PostPosted: Wed Mar 25, 2009 4:38 am
by uday123
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

Re: What does this piece of code mean?

PostPosted: Wed Mar 25, 2009 6:56 am
by dick scherrer
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.

Re: What does this piece of code mean?

PostPosted: Wed Mar 25, 2009 3:42 pm
by uday123
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

Re: What does this piece of code mean?

PostPosted: Thu Mar 26, 2009 12:15 am
by dick scherrer
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.

Re: What does this piece of code mean?

PostPosted: Thu Mar 26, 2009 5:49 am
by uday123
Thanks Scherrer.. Really worked out looking at the parenthesis.. Previously i did not pay much attention to that. :)

Regards
Uday

Re: What does this piece of code mean?

PostPosted: Thu Mar 26, 2009 6:20 am
by dick scherrer
You're welcome - good luck :)

d