tbug754.pp 1.8 KB

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