Controlling and Dependent Attributes
Controlling and dependent attributes provide a method for creating sublists for items. A controlling attribute is one which has the code D1 in attribute 8 of its data definition item and points to its dependent attributes. A dependent attribute is one which has the code D2 and points to its controlling attribute.
For example, the GUESTS file has a controlling attribute (10) that holds bill codes, a dependent attribute (11) that holds the date of each bill, and another dependent attribute (12) that holds each bill amount. Each of these attributes is multivalued. An item in the file is similar to the following:
122 001 7187 (Arrival date, internal format) 002 Anderson (Last name) 003 Richard (First name) 004 153 Windsor Dr. (Street address) 005 Concord (City) 006 NH (State) 007 34598 (Zip code) 008 USA (Country) 009 AMEX (Type of payment/credit card) 010 8]2]9 (Bill codes) 011 7188]7192]7195 (Bill date, internal format) 012 14.45]56.00]16.00 (Bill amounts)
The controlling and dependent attributes have a one-to-one relation for each value in the sublists. In the example, bill code 8 of attribute 10 relates only to the data before the first value mark (]) of attributes 11 and 12. Bill code 2 relates only to the data before the second value mark, and so on.
The code in data definition item BILL-CODE is
008 D1;11;12
The codes in data definition items BILL-DATE and BILL-AMOUNT are, in part,
008 D2;10
These make BILL-CODE the controlling attribute, pointing to AMC 11 and 12. BILL-DATE and BILL-AMOUNT are dependent, pointing to AMC 10.
Action by English
When the English processor sees a controlling attribute, it
-
Looks for the first attribute specified in the output specification clause that matches each AMC of its dependent attributes.
-
Positions the found attributes, in the order found, to the immediate right of the controlling attribute for display.
-
Displays an asterisk (
*) under the column heading of each found attribute. -
Ignores dependent attributes until a controlling attribute triggers a search to match an AMC.
Comments
The processor is designed to display dependent attributes immediately to the right of their controlling attribute. It tries to do this no matter in what order you specify the controlling and dependent attributes in the output specification clause. For this reason you should specify a controlling attribute followed immediately by any of its dependent attributes that you wish displayed.
If you must specify an independent attribute that has the same AMC as an attribute that is dependent on a controlling attribute, place the independent attribute somewhere to the right of the dependent attribute.
To output the data from a dependent attribute, you must specify the controlling attribute in the output specification clause; otherwise, the processor ignores the dependent attribute.
Any independent attribute inserted between the controlling and dependent attributes in the output specification clause is moved to the right of the controlling and dependent attributes.
Examples
:LIST GUESTS NAME BILL-CODE BILL-AMOUNT BILL-TOTAL GUESTS Guest Name Bill Amount Bill Total Code * 401 Sharon R.Palmer 2 $56.00 $149.25 6 $19.00 2 $56.00 6 $18.25 147 Loretta T.Janson 2 $56.00 $122.82 . . . :LIST GUESTS NAME BILL-AMOUNT BILL-TOTAL BILL-CODE (C 401 Sharon R.Palmer $149.25 2 $56.00 6 $19.00 2 $56.00 6 $18.25 147 Loretta T.Janson $122.82 2 $56.00 . . .<Return>
Attributes NAME and BILL-TOTAL are independent attributes; BILL-CODE is a controlling and BILL-AMOUNT a dependent attribute as shown by the asterisk above the column of data.
In the first example, the output specification is in the following order:
NAME BILL-CODE BILL-AMOUNT BILL-TOTAL
The resulting report is generated in the order specified. However, the order specified in the second example causes the report to be rearranged as follows:
NAME BILL-AMOUNT BILL-TOTAL BILL-CODE
Here the independent attribute BILL-TOTAL is moved to the left of the controlling attribute BILL-CODE and the dependent attribute BILL-AMOUNT is moved to the right of BILL-CODE.