User Tools

Site Tools


addpair_add_a_field_pair_fieldpairsclass_.htm
Navigation:  ABC Library Reference > FieldPairsClass > FieldPairsClass Methods >====== AddPair (add a field pair:FieldPairsClass) C6H0009.jpg ====== Previous pageReturn to chapter overviewNext page

AddPair( left, right ), VIRTUAL

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, List

addpair_add_a_field_pair_fieldpairsclass_.htm.txt · Last modified: 2021/04/15 15:56 by 127.0.0.1