Creating array to substitute the below cobol statment
Posted:
Thu May 08, 2008 11:40 am
by anoopm7
Hi All,
Could any one guide me for creating array to substitute the below cobol statment's
When 1
Add +1 to choice-1
When 2
Add +2 to choice-2
.
.
.
.
When 140
Add +140 to choice-140
your help is deeply appreciated.
Thanks
Re: Array creation.
Posted:
Thu May 08, 2008 5:15 pm
by arunprasad.k
Code something like.
WORKING-STORAGE SECTION.
01 CHOICE-TABLE.
05 CHOICE PIC 9(08) OCCURS 140 TIMES.
PROCEDURE DIVISION.
IF NOT (N < 1 AND N > 140)
ADD +1 TO CHOICE(N)
ELSE
YOUR WHEN OTHERS CASE
END-IF.
Where n is the value in the evaluate class.
Post if you have any problems. Arun
Re: Array creation.
Posted:
Thu May 08, 2008 6:23 pm
by dick scherrer
Hello,
Please note in the posted suggestion, there is no initial value in the counters. They should be set to zero before being used as accumulators. As is, invalid totals may result or an abend may occur.
I am also not sure about the requirement that adds 1 when the "value" is a 1 and adds 2 when the "value" is a 2 and so on. I believe that the suggested code (which is not the same as the request) is what is needed.