[fpc-pascal]How to assign a file? Please help

Martin Hankovec Martin.Hankovec at oku-st.cz
Wed Feb 14 13:58:51 CET 2001

>Could you please provide a compilable source
>as small as possible that demonstates your problem ?
The source can be found in documentation under
BlockRead - example. But I use a unit for delivering
of all files in directories and subdirectories,so it's hard to
give all the source (maybe on private mail).

If You try to run the example from documentation (copying files,
example from BlockRead in System unit) and run it on 10 or
more files, it will copy only some files (by me on NT4.0 only five files,
on Win9x maybe more). Then it will give an error of "Too many files open".
(Every file is assigned,opened and CLOSED!!!).

Now I tried to use the Sysutils unit,and this work fine.

Simple example,that didn't work for me,and demonstrates the error:
procedure test(name:string);
var fin:file;
  assign(fin,name);  {assign it}
  reset(fin,1);   {open for reading}
  if ioresult<>0 then writeln('Error!!');
  close(fin);     {do nothing and close it immediately}
And call this procedure on many files. After some openings it returns an error
(Too many files opened).

With Sysutils (fileread,fileopen etc.) it works, maybe an error in System unit ?

Thanks for advice.

Martin H.

More information about the fpc-pascal mailing list