tbug754.pp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. program test_open_files;
  2. const
  3. MaxOpenTest = 150;
  4. var
  5. f : array [1..MaxOpenTest] of text;
  6. i,count : longint;
  7. s : string;
  8. storeexit : pointer;
  9. procedure Errorexit;
  10. begin
  11. exitproc:=storeexit;
  12. if errorcode=4 then
  13. begin
  14. if count<=15 then
  15. begin
  16. Writeln('The program could not open more than 15 files !');
  17. Writeln('Retry after addition of the following line to config.sys file');
  18. Writeln('FILES=60');
  19. Writeln('If it still does not work after this change');
  20. Writeln('you probably use a too old RTL version');
  21. Writeln('that does not support more than 15 files');
  22. Writeln('open at the same time');
  23. end
  24. else
  25. begin
  26. Writeln('The program was able to open ',count,' files simultaneously');
  27. Writeln('If you need to be able to have more opened files');
  28. Writeln('Try to increase the FILES=XX value in config.sys file');
  29. { This is not a RTL error anymore
  30. as we increased the size over the ordinary 15 limit }
  31. erroraddr:=nil;
  32. errorcode:=0;
  33. exitcode:=0;
  34. end;
  35. { close all left open files }
  36. for i:=count downto 1 do
  37. close(f[i]);
  38. end;
  39. end;
  40. begin
  41. StoreExit:=exitproc;
  42. ExitProc:=@ErrorExit;
  43. for i:=1 to MaxOpenTest do
  44. begin
  45. str(i,s);
  46. s:='file'+s+'.tmp';
  47. assign(f[i],s);
  48. rewrite(f[i]);
  49. count:=i;
  50. Writeln(f[i],'This is file ',i);
  51. Writeln(i,' files open');
  52. { no closing so they are finally all open }
  53. end;
  54. for i:=MaxOpenTest downto 1 do
  55. close(f[i]);
  56. end.