type recordTypeName = record fieldList1: type1; ... fieldListn: typen; case tag: ordinalType of constantList1: (variant1); ... constantListn: (variantn); end;
...{$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); begin //初始化是为记录赋值 with pp[0] do begin Fname :='PP0'; typeid := Files; //fsize和dsize实际用的是同一块存储空间, //这里两个都赋值了,存储空间中记录的自然是后者 Fsize :=10; Dsize :=100; ContainFileCount :=1; ContainDirCount :=2; end; with pp[1] do begin Fname :='PP1'; typeid := Dirs; Fsize :=0; Dsize :=100; ContainFileCount :=11; ContainDirCount :=222; end; Memo1.Clear; ShowInfo; end;
procedure TForm1.ShowInfo; var i : integer; fs : string; begin Memo1.Lines.Add('变体记录信息显示'); for i :=0 to 1do begin fs := Format('PP%d 的大小是(%d)'+#13+'Fsize:(%d),Dsize:(%d)'+#13+'ContainFileCount:(%d),CDirCount:(%d);' ,[i,sizeof(pp[i]),pp[i].Fsize,pp[i].Dsize,pp[i].ContainFileCount,pp[i].ContainDirCount]); Memo1.Lines.Add(fs); Memo1.Lines.Add('------------------------'); end;
end;
procedure TForm1.Button1Click(Sender: TObject); begin Memo1.Clear; end;