ex23.pp 581 B

123456789101112131415161718192021222324252627282930
  1. Program Example23;
  2. { Program to demonstrate the FilePos function. }
  3. Var F : File of Longint;
  4. L,FP : longint;
  5. begin
  6. { Fill a file with data :
  7. Each position contains the position ! }
  8. Assign (F,'test.dat');
  9. Rewrite (F);
  10. For L:=0 to 100 do
  11. begin
  12. FP:=FilePos(F);
  13. Write (F,FP);
  14. end;
  15. Close (F);
  16. Reset (F);
  17. { If all goes well, nothing is displayed here. }
  18. While not (Eof(F)) do
  19. begin
  20. FP:=FilePos (F);
  21. Read (F,L);
  22. if L<>FP then
  23. Writeln ('Something wrong: Got ',l,' on pos ',FP);
  24. end;
  25. Close (F);
  26. Erase (f);
  27. end.