![]() |
|
#13
|
|||
|
|||
![]() Цитата:
Вопрос первый: ошибка. Incompatible types: byte and cardinal Листинг: Код:
var Form1: TForm1; f : file of byte; b : byte; zol : dword; implementation {$R *.dfm} procedure TForm1.FormActivate(Sender: TObject); begin AssignFile(f, 'savegame00.sav'); FileMode := fmOpenReadWrite; Reset(f); Seek(f, 186747); Read(f, b); Seek(f, 186748); ??? Read(f, zol); CloseFile(f); Edit1.Text := IntToStr(b); Edit2.Text := IntToStr(zol); end; Вопрос второй (сделал по-своему): можно ли упростить код? И вопрос вдогонку: что делать, если побайтовый offset на 4 делиться не будет? (186748/4 = 46687, но так может быть не всегда) Листинг: Код:
var Form1: TForm1; f : file of byte; b : byte; ff : file of cardinal; zol : dword; implementation {$R *.dfm} procedure TForm1.FormActivate(Sender: TObject); begin AssignFile(f, 'savegame00.sav'); FileMode := fmOpenReadWrite; Reset(f); Seek(f, 186747); Read(f, b); AssignFile(f, 'savegame00.sav'); FileMode := fmOpenReadWrite; Reset(ff); Seek(ff, 46687); Read(ff, zol); //CloseFile(ff); Edit1.Text := IntToStr(b); Edit2.Text := IntToStr(zol); end; |