[ < ] | [ > ] |  | [ << ] | [ Up ] | [ >> ] |  |  |  |  | [Top] | [Contents] | [Index] | [ ? ]

#### 8.2.10.5 Variant Records

GPC supports variant records like in EP and BP. The following construction is not allowed in Extended Pascal, but in BP and GPC:

    program BPVariantRecordDemo;

    type
      PersonRec = record
        Age: Integer;
      case EyeColor: (Red, Green, Blue, Brown) of
        Red, Green : (WearsGlasses: Boolean);
        Blue, Brown: (LengthOfLashes: Integer);
      end;

    begin
    end.

In EP, the variant field needs a type identifier, which, of course, also works in GPC:

    program EPVariantRecordDemo;

    type
      EyeColorType = (Red, Green, Blue, Brown);

      PersonRec = record
        Age: Integer;
      case EyeColor: EyeColorType of
        Red, Green : (WearsGlasses: Boolean);
        Blue, Brown: (LengthOfLashes: Integer);
      end;

    begin
    end.

This document was generated by Frank Heckenbach on May, 10 2002 using texi2html