Getting Started with TRANSACT (32247-90007)

136 Chapter8
Special Topics
Arrays
In this example, the definition of the array makes no reference to the number of years or
the number of months in a year. It is just 500 bytes long, which is the same as the previous
example of 10 years by month where the data for each year is a 2-digit year and 12 months
of 4 bytes each.
The only items that will ever be referred to in this array are ot-year and ot-mo. These are
the only items defined and the definition of them does not indicate where they are within
the array. The definition only establishes that they are child items of the array, and
references to them will be made relative to the start of the array.
This means that before we address either of these items, we must fully establish the byte
offset of each.
Line 43.1 establishes the byte offset for ot-year. There is no difference between this and the
previous example. The reason is that both examples define ot-year relative to the start of
the array.
Line 55 establishes the byte offset for ot-mo. Here there is a big difference between this
and the previous example. The previous example defined the start of the months to be
relative to the start of a year plus 2 bytes. The start of a year was defined relative to the
start of the array. In the current example, ot-mo was defined relative to the start of the
array. Therefore its byte offset must account for the year offset plus the month offset
within year plus the fact that the start of the months for a year are offset from the start of
a year by 2 bytes to allow for storage of a 2-byte year number.
Looking at line 55 and relating it to the above, we already know the year offset since we set
it in line 43.1. Thus we can include it by specifying OFFSET(ot-year) which is equivalent
to the calculation (indx) * 50. Each month is 4 bytes long, so the offset of the month we
want to reference relative to zero is [(date-mm) - 1] * 4. Finally, the first month of a year is
offset by 2 bytes from the beginning of each year's data.