![]() |
|
|
|||||||
| Регистрация | << Правила форума >> | FAQ | Пользователи | Календарь | Поиск | Сообщения за сегодня | Все разделы прочитаны |
![]() |
|
|
Опции темы | Поиск в этой теме | Опции просмотра |
|
#1
|
|||
|
|||
|
Тут уже bыла тема по этому поводу, и я туда не могу писать потому что она "слишком старая" но у меня таки не раbотает
вываливается EInOutError: read past end of file даже при bанальном seek(f,FileSize(f)) write(f,500); |
|
#2
|
||||
|
||||
|
хоть бы простейший пример реализующий проблему привел...
|
|
#3
|
|||
|
|||
|
Код:
procedure FnegativeTemp(var Fx:RealFile); var i:integer; Ntemp:real; NArray:array[1..20] of real; begin assign(Fx,'temp.dat'); reset(Fx); for i:=1 to FileSize(Fx) do begin read(Fx,Ntemp); seek(fx,FileSize(Fx)); if Ntemp<0 then begin Narray[i]:=Ntemp; write(Fx,Narray[i]); seek(Fx,i); end; end; close(Fx); end; как-то так, файл уже существует и в нем 10 чисел |
|
#4
|
||||
|
||||
|
все честно работает:
Код:
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; |