Getting Started with TRANSACT (32247-90007)

Chapter 8 131
Special Topics
Arrays
Lines 2 through 6 define the array. The array is intended to hold up to 10 years of data by
month. The data that is to be accumulated into the table is the order quantity for each
order and part number.
Line 2 specifies that the first dimension of the array is 10 years of information. At this
time, we must also specify the total byte length of all information for a year (which is 50).
As discussed below, the 50 bytes for each year contain a 2-byte year number and 12
monthly quantities of 4 bytes each.
Line 3 defines a parent item for one year in the array.
Lines 4 and 5 define the child items that make up a year. A subscript will be used to access
a year and a byte offset via the LET OFFSET verb will be used to access a month within a
year.
Line 5 also defines the parent item for one year of information by month. Line 6 defines a
month within the year.
Line 44 uses the subscript indx to access the year in the array. If the value of the year in
the array is the same as the value of the year in the input record, we have resolved the
year to accumulate to. If it does not, then the loop is iterated until the matching year is
found or the end of the array is reached. If the end of the array is reached, a new entry is
made into the array, storing the new year number (line 51).
Line 55 specifies the byte offset for a month relative to its parent item. Since the length of
data for each month is 4 bytes, the offset for the n th month is (n - 1) * 4. Use of LET
OFFSET specifies the starting byte position relative to the base. The base is zero. Thus the
first month has a zero offset, the second month has an offset of 4, which is the length of the
item ot-mo.
The above example illustrates using both subscripts and LET OFFSET to access a
multi-dimensional array.
The following example illustrates using LET OFFSET exclusively to access the array.