[<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
records                  Collection of Data Fields             Data Structure

    Pascal allows you to define a group of unrelated data types into one
    structure, called a record. The general format is:

         type
           <tname> = record
             <fnames>  : <type>;
             <fnames>  : <type>;
             ...
             <fnames>  : <type>
           end;

         var
           <vname> : record
             <fnames>  : <type>;
             <fnames>  : <type>;
             ...
             <fnames>  : <type>
           end;

    where <tname> and <vname> are identifiers for data types and
    variables, respectively. <fnames> is a list of one or more field names
    and <type> is any data type, including records, arrays, sets, and
    files.

    Individual fields in a record are accessed by using the following
    notation:

         <rname>.<fname>

    This will access the field named <fname> of the record named <rname>.

    Records can be nested; that is, a record can be defined within a
    record. To access a field of a nested record, the notation below is
    used:

         <rname1>.<rname2>. ... .<rnameN>.<fname>

    where the record names are <rnamen> and the field is named <fname>.

  -------------------------------- Example ---------------------------------

           type
             MyRec = record;
               Cnt  : Integer;
               List : array[1..10] of Char;
               Flag : Boolean;
               Num  : Real
             end;

           var
             Able,Iota,Fred : MyRec;

           begin
             Able.Flag := False;
             Iota.List[3] := '%';
             Fred.Num := 89.228
           end.

See Also: record with
This page created by ng2html v1.05, the Norton guide to HTML conversion utility. Written by Dave Pearson