Getting Started with TRANSACT (32247-90007)

Chapter 6 105
Data Structures
In this example program, the data storage always exists in one of two forms. When lines 15
to 18 and 26 to 27 are executed, the data storage looks like:
Figure 6-16. LIST Register Map with Same Item Twice
During the remainder of the program, the data storage looks like:
Figure 6-17. LIST Register After SET(STACK)
This is all controlled by the repeated execution of lines 14.1 and 18.1. Line 14.1 reserves
space for the item quantity. It will hold the inventory quantity at a location while line 17 is
executing. Line 18.1 deallocates this space after we have computed the total inventory
balance.
How does Transact know which quantity we want to use in line 26? It doesn't. Whenever a
program instructs Transact to perform some action on a data item, Transact always uses
the most recently defined (LISTed) version of the item. Once line 14.1 has been executed,
there is no way we can ever access the space reserved for quantity by lines 5 to 7 until we
execute line 18.1.
In the example above, we could also have written line 18.1 as:
Figure 6-18. Removing the Last Item Name from the LIST
This deallocates the last data item defined (LISTed) to Transact.
A slightly more general purpose way to implement the last example is to use marker items.
Just as their name implies, these items mark a data storage reference point that we can go
back to. Or they can be used in pairs to delimit a set of data that pertains to a file or
dataset. A marker is just a name and does not physically take up any data storage space.
5 part-number
6 quantity
8 tot-inv
14.1 quantity
5 part-number
6 quantity
8 tot-inv
18.1 set(stack) list (*);