| **Navigation:**  [[abc library reference.htm|ABC Library Reference]] > FieldPairsClass > FieldPairsClass Methods >====== AddPair (add a field pair:FieldPairsClass) {{c6h0009.jpg|C6H0009.jpg}} ====== | [[additem add a field pair from one source field .htm|{{btn_prev_n.gif|Previous page}}]][[abc library reference.htm|{{btn_home_n.gif|Return to chapter overview}}]][[assignlefttoright copy from left fields to right fields .htm|{{btn_next_n.gif|Next page}}]] | | || **AddPair(**// left, right //**), VIRTUAL** {{blk2blue.jpg|blk2blue.jpg}} | **AddPair** | Adds a field pair to the List property. | | //left// | The label of the "left" field of the pair. The field may be any data type, but may not be an array. | | //right// | The label of the "right" field of the pair. The field may be any data type, but may not be an array. | The **AddPair **method adds a field pair to the List property. The fields need not be contiguous in memory, nor do they need to be part of a structure. Therefore you can build a virtual structure simply by adding a series of otherwise unrelated fields to a FieldPairs object. The other FieldPairs methods then operate on this virtual structure. **Implementation:** AddPair assumes the List property has already been created by Init or by some other method. By calling AddPair for a series of fields (for example, the corresponding fields in a RECORD structure and a QUEUE structure), you effectively build two virtual structures containing the fields and a (one-to-one) relationship between the two structures. **Example:** ** INCLUDE('ABUTIL.INC')            !declare FieldPairs Class** **Fields  FieldPairsClass           !declare FieldPairs object** **Customer FILE,DRIVER('TOPSPEED'),PRE(CUST)** **ByNumber KEY(CUST:CustNo),NOCASE,OPT,PRIMARY** **Record   RECORD,PRE()** **CustNo    LONG** **Name      STRING(30)** **Phone     STRING(20)** **ZIP       DECIMAL(5)** **         END** **         END** **CustQ   QUEUE** **CustNo   LONG** **Name     STRING(30)** **Phone    STRING(20)** **ZIP      DECIMAL(5)** **        END** ** CODE** ** Fields.Init                               !initialize FieldPairs object** ** Fields.AddPair(CUST:CustNo, CustQ.CustNo) !establish CustNo pair** ** Fields.AddPair(CUST:Name,  CustQ.Name)    !establish Name pair** ** Fields.AddPair(CUST:Phone, CustQ.Phone)   !establish Phone pair** ** Fields.AddPair(CUST:ZIP,  CustQ.ZIP)      !establish ZIP pair** **See Also:**     [[init initialize the fieldpairsclass object .htm|Init]], [[list recognized field pairs .htm|List]]