[fpc-pascal]files handler in FPC
Adam Naumowicz
adamn at math.uwb.edu.pl
Thu Mar 7 02:23:53 CET 2002
On 6 Mar 2002, [iso-8859-2] £ukasz Le¶niak wrote:
> procedure ReadDataFromFile(var s: SetOfperson)
> var i, F: LongInt;
> p: SetOfPerson;
> .
> .
> i:=0;
> F:=FileOpen(path_to_F, fmOpenRead);
> if F = -1 then Halt(1);
> new(p);
> FileSeek(F, i, fsFromBeginning);
> FileRead(F, p^.desc, SizeOf(p^.desc));
> (* XXX *)
> p^.next:=s;
> s:=p;
> i:= i + 1;
> end;
Even if you have a loop there is still one more thing:
if you want to read the file sequentially there is no need to set the file
position with FileSeek since FileRead changes the current position. But
anyway, if you read a raw data type (as in this case) you should increment
the position by SizeOf buffer, not by 1.
Best regards,
Adam Naumowicz
--------------------------------------
WWW: http://math.uwb.edu.pl/~adamn/
--------------------------------------
More information about the fpc-pascal
mailing list