On Wednesday, September 15, 2021 at 1:13:59 AM UTC-4,
[email protected] wrote:
So I have an array created by defining with an occurs. Let's say I have OCCURS 10 TIMES. When it comes to the PERFORM VARYING (or whatever) is
there a way to iterate through the rows in the array without specifying
the same number of rows in the PERFORM, that is, the compiler knowing
how many rows are defined in WORKING-STORAGE, it can limit the number of iterations in the PERFORM?
COBOL tables are often defined to be larger than the apparent
need because the number of entries may be variable. That is,
a table may be defined as OCCURS 100, when the number of
entries determined during design may be 1 to 50. Sometimes
designs change.
It is not uncommon to define both a limit and a count for
the number of entries available and used, respectively.
For example,
01 t1-limit comp pic 9(4) value 100.
01 t1-count comp pic 9(4) value 0.
01 t1-index comp pic 9(4) value 0.
01 t1-table.
03 t1-entry occurs 100.
05 (the description of the entry)
When loading a table, one may do something like.
add-entry.
if t1-count not > t1-limit
add 1 to t1-count
move new-entry to t1-entry (t1-count)
else
perform error-proc-t1-no-space
end-if
.
When using PERFORM to find an entry, one may do.
find-entry.
perform varying t1-index from 1 by 1
until t1-index > t1-count
or (whatever search criteria)
end-perform
.
Tables are not just in the WORKING-STORAGE SECTION, they
may be placed in the FILE SECTION, LOCAL-STORAGE SECTION
and LINKAGE SECTION.
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)