28.09.2015, 09:32
|
|
Let Me Show You
|
|
Регистрация: 30.04.2010
Адрес: Северодвинск
Сообщения: 5,426
Версия Delphi: 7, XE5
Репутация: 59586
|
|
все честно работает:
Код:
type
TFileRec = packed record
id: Integer;
note: string[11];
end;
var
f: file of TFileRec;
r: TFileRec;
begin
(* создаем файл и запишем в него 2 записи *)
AssignFile(f, 'Project1.txt');
Rewrite(f);
r.id:=1;
r.note:='hello';
Write(f, r);
r.id:=2;
r.note:='world';
Write(f, r);
CloseFile(f);
(* прочитаем их в Memo1 *)
AssignFile(f, 'Project1.txt');
Reset(f);
while not Eof(f) do
begin
Read(f, r);
Memo1.Lines.Add(IntToStr(r.id)+string(r.note));
end;
CloseFile(f);
(* добавим в конец еще 2 записи *)
AssignFile(f, 'Project1.txt');
Reset(f);
Seek(f, FileSize(f));
r.id:=3;
r.note:='привет';
Write(f, r);
r.id:=4;
r.note:='мир';
Write(f, r);
CloseFile(f);
(* прочитаем их в Memo2 *)
AssignFile(f, 'Project1.txt');
Reset(f);
while not Eof(f) do
begin
Read(f, r);
Memo2.Lines.Add(IntToStr(r.id)+string(r.note));
end;
CloseFile(f);
end;
__________________
Пишу программы за еду.
__________________
|