views:

42

answers:

2

what keywords must be used to create a variant record??

A: 

case: Consider this standard example from http://docs.embarcadero.com/products/rad_studio/delphiAndcpp2009/HelpUpdate2/EN/html/devcommon/structuredtypes_xml.html

TEmployee = record
  FirstName, LastName: string[40];
  BirthDate: TDate;
  case Salaried: Boolean of
    True: (AnnualSalary: Currency);
    False: (HourlyWage: Currency);
end;
Andreas Rejbrand
A: 

@osabiri check the documentation for free pascal related to records.

Type  
  MyRec = Record  
          X : Longint;  
          Case byte of  
            2 : (Y : Longint;  
                 case byte of  
                 3 : (Z : Longint);  
                 );  
          end; 

Important Note :

The variant part must be last in the record. The optional identifier in the case statement serves to access the tag field value, which otherwise would be invisible to the programmer. It can be used to see which variant is active at a certain time1 . In effect, it introduces a new field in the record.

check theses links

RRUZ