dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Code: |
77 the-hour pic 9(3) comp-3 value 1.
77 the-minute pic 9(3) comp-3 value 1.
01 two-dimension-table.
05 hours-dim occurs 24 times.
10 mins-dim occurs 60 times.
15 a-counter pic 9(7) comp-3.
|
Let's say you had "something" that could happen multiple times a minute and you want to count how many times it happened for each hour/minute for some period of time (the input is NOT in hour/minute sequence). You could use the hour and minute to point to the "counter" for that time and add to it as appropriate.
The arrays need to be initialized to zeros before processing starts.
In the program, the "hour and minute" are moved/calculated from the input to the 2 corresponding 77-level fields.
Your code would then be:
Code: |
add 1 to a-counter(the-hour, the-minute). |
When the input has all been processed, a loop could be used to process all of the a-counter entries for all of the hours/minutes. |
|