Page 1 of 2

VALUE Clause!!

PostPosted: Sun Oct 03, 2010 3:13 pm
by sivanag
HI...

it s all abt VALUE Cluse..

i want initialize data-names as shown below

77 male pic 9(2) value '1','2'.
77 female pic 9(2) value '2','3'.
77 value pic9(1).

procedure division.

accept value.

if value='1'
display 'male'.

if value='2'
display 'male&female'
else
display 'female'.

is this code will work??

plz help me...

regard
Sivanag

Re: VALUE Clause!!

PostPosted: Sun Oct 03, 2010 5:53 pm
by Robert Sample
What you have coded will not work. Look up 88 levels in the COBOL Language Reference manual.

Re: VALUE Clause!!

PostPosted: Sun Oct 03, 2010 10:01 pm
by dick scherrer
Hello,

You also need to look at how the IFs are coded.

As coded, you will never see only "male". . .
When the value is 1, "male" will be displayed. Then "female" will be displayed. . .

Re: VALUE Clause!!

PostPosted: Thu Oct 14, 2010 1:35 pm
by shindeswap
01 Gender
88 male values '1','2'.
88 female value '2','3'.

procedure division.

accept gender.

if gender='1'
display 'male'.

if gender='2'
display 'male&female'
else if gender='3'
display 'female'.

Try this and confirm

Re: VALUE Clause!!

PostPosted: Fri Oct 15, 2010 12:09 am
by dick scherrer
Hello,

Why are there 88 level entries? They are not referenced.

"Gender" needs a picture. . .

Re: VALUE Clause!!

PostPosted: Fri Oct 15, 2010 6:07 pm
by Ferrari2010
Hi,

You can use below simple logic to check how 88 level works.
below code may have syntax errors, please take care.

01 GENDER PIC X (01).
88 MALE VALUE '1'.
88 FEMALE VALUE '1'.

PROCEDURE DIVISION.

DISPLAY " ENTER THE CODE".
ACCEPT GENDER

IF MALE
DISPLAY " ENTERED VALUE: 1"
ELSE IF FEMALE
DISPLAY " ENTERED VALUE: 2"
ELSE
DISPLAY "INVALID ENTRY"
END-IF.

Thanks,

Re: VALUE Clause!!

PostPosted: Fri Oct 15, 2010 11:22 pm
by NicC
Yes - it has errors. FEMALE should have VALUE 2.

You should cut and paste from a working program.

Re: VALUE Clause!!

PostPosted: Sat Oct 16, 2010 1:45 am
by dick scherrer
Hello,

The code posted by Ferrari2010 does not follow the original "rules". . .

As Nic mentioned, the code is also wrong.

Please do not post "solutions" that have not been tested and meet the requirement. . .

Re: VALUE Clause!!

PostPosted: Thu Oct 21, 2010 6:22 pm
by ritikasingh
As a suggestion if you are looking at same variable in if loop many times , its better to use EVALUATE as per my opinion.As i think in 'IF' even though the first condition has met successfully it will keep going the if loop taking more time.

Re: VALUE Clause!!

PostPosted: Thu Oct 21, 2010 6:38 pm
by Robert Sample
Why do you think when you can read section 6.2.19.2 of the COBOL Language Reference manual and know for sure -- especially when what you think is wrong. If the first IF statement is true, and the DISPLAY 'ENTERED VAUE: ' 1 is executed, the next statement to be executed will be the statement after the period (or corresponding END-IF if one was specified -- which there wasn't in the posted example).