TAL Programmer's Guide
Declaring Substructures
Using Structures
096254 Tandem Computers Incorporated 8–13
Declaring Multidimensional Arrays
You can nest substructures in a structure to simulate a multidimensional array.
The following structure simulates a two-dimensional array. The structure represents
two warehouses. The two substructures represent 50 items and ten employees in each
warehouse. The substructures are both nested at the second level but contain different
kinds of records:
LITERAL last = 49; !Declare number of last item
STRUCT .warehouse[0:1]; !Declare structure WAREHOUSE
 BEGIN
 STRUCT inventory[0:last]; !Declare substructure
 BEGIN ! INVENTORY
 INT item_number;
 INT price;
 INT on_hand;
 END; !End INVENTORY
 STRUCT employee[0:9]; !Declare substructure
 BEGIN ! EMPLOYEE
 STRING name[0:31];
 STRING telephone[0:6];
 END; !End EMPLOYEE
 END; !End WAREHOUSE
The following structure simulates a five-dimensional array. The structure represents a
corporation that contains three branches. Each branch contains four divisions. Each
division contains up to six departments. Each department contains up to six groups.
Each group contains up to 20 employees.
STRUCT .corp; !Declare structure CORP
 BEGIN
 STRUCT branch[0:2]; !Declare substructure BRANCH
 BEGIN
 STRUCT div[0:3]; !Declare substructure DIV
 BEGIN
 STRUCT dept[0:5]; !Declare substructure DEPT
 BEGIN
 STRUCT group[0:5]; !Declare substructure GROUP
 BEGIN
 STRUCT employee[0:19]; !Declare substructure
 BEGIN ! EMPLOYEE
 STRING name[0:31];
 STRING telephone[0:6];
 END; !End EMPLOYEE
 END; !End GROUP
 END; !End DEPT
 END; !End DIV
 END; !End BRANCH
 END; !End CORP










