record 的一个小问题
unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons;type TMapRec = record X, Y: Integer; ImageName: string[10]; end;type TForm1 = class(TForm) SpeedButton1: TSpeedButton; procedure SpeedButton1Click(Sender: TObject); private { Private declarations } Fs: TFileStream; FileSize: Integer; MapData: array of TMapRec; public { Public declarations } end;var Form1: TForm1;implementation{$R *.dfm}procedure TForm1.SpeedButton1Click(Sender: TObject);begin MapData[0].X := 1; //这里出错! 怎么赋值才不会出错呢? MapData[0].Y := 1; MapData[0].ImageName := 'T1'; MapData[1].X := 2; MapData[1].Y := 2; MapData[1].ImageName := 'T2'; Fs := TFileStream.Create('C:\Users\Ekmin\Desktop\1.txt', fmOpenWrite); //Fs.WriteBuffer(FileSize, SizeOf(FileSize)); SetLength(MapData, FileSize); Fs.WriteBuffer(MapData[0], SizeOf(TMapRec) * FileSize); Fs.Destroy;end;end.