2
0

ex37.pp 590 B

12345678910111213141516171819202122232425262728293031
  1. Program Example37;
  2. { This program demonstrates the FileCreate function }
  3. Uses sysutils;
  4. Var I,J,F : Longint;
  5. Begin
  6. F:=FileCreate ('test.dat');
  7. If F=-1 then
  8. Halt(1);
  9. For I:=0 to 100 do
  10. FileWrite(F,I,SizeOf(i));
  11. FileClose(f);
  12. F:=FileOpen ('test.dat',fmOpenRead);
  13. For I:=0 to 100 do
  14. begin
  15. FileRead (F,J,SizeOF(J));
  16. If J<>I then
  17. Writeln ('Mismatch at file position ',I)
  18. end;
  19. FileSeek(F,0,0);
  20. Randomize;
  21. Repeat
  22. FileSeek(F,Random(100)*4,0);
  23. FileRead (F,J,SizeOf(J));
  24. Writeln ('Random read : ',j);
  25. Until J>80;
  26. FileClose(F);
  27. End.