View previous topic :: View next topic
|
Author |
Message |
sivakumar M
New User
Joined: 03 Jul 2011 Posts: 8 Location: india
|
|
|
|
Hi All,
I do have question in OCCURS class in COBOL. I have an array which is of length 100. In that array if I need to know the count of filled element, is there a way to do it through any keyword?
I can do it by reading the array until it meets the NULL value and I can display the count value. But is there any short way to do it?
Example:
A(1) = 5
A(2) = 8
A(3) = NULL
A(4) = NULL
Required O/P = 2; Please suggest me. |
|
Back to top |
|
|
Bill Woodger
Moderator Emeritus
Joined: 09 Mar 2011 Posts: 7309 Location: Inside the Matrix
|
|
|
|
No arrays in Cobol. Table, yes. The length of a Cobol table is length of occurs item time no of occurs.
To your question, don't you keep track of what you put in the table, so that you know how many are there all along without having to do any sort of other stuff? If you read this from a file, there should be a count of the no of entries occupied on the file. |
|
Back to top |
|
|
Bill O'Boyle
CICS Moderator
Joined: 14 Jan 2008 Posts: 2501 Location: Atlanta, Georgia, USA
|
|
|
|
You could -
01) Keep a counter-variable in WS, adding one to the counter each time an element is added.
02) Use the SEARCH Verb until you find an element that equals LOW-VALUES. To avoid the SEARCH, check element number 100 for not equal to LOW-VALUES (Table is FULL) as well as element number 001 for equal to LOW-VALUES (Table is EMPTY).
Mr. Bill |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
NULL is not a value - it is a condition. Do you mean x'00' or x'40' or something is "null"?
When you put things into the array, you could save a "high-water" mark and know without looking which was the last element used. . . |
|
Back to top |
|
|
|