next up previous contents index
Next: Parallel Arrays Up: Derived Types Previous: Derived Types

Records

    Records provide a way to associate related data into a single data structure. A record consists of one or more fields that each have a name and a type. The type of a field may be any base or derived type. The names must be unique within each record type, but each record type defines a new lexical scope. A record can be declared as illustrated below:

    type person = record
           age    : integer;
           weight : integer;
         end;
Individual fields of a record are accessed using the dot operator (.):

    var  daphne : person;

    daphne.age := 10;
Records can be assigned or passed as parameters to procedures as whole entities. When records are passed as value parameters the entire record is copied, including any array fields. Passing large records by value will incur an expensive copy. Therefore records should be passed by var when possibly to avoid the cost of copying.



Kay Nettle
Fri Feb 21 21:14:29 CST 1997