[fpc-pascal]Loop Question!!!!
Gabor DEAK JAHN
djg at argus.vki.bke.hu
Tue Nov 30 17:40:17 CET 1999
At 11/29/2000 06:29, you wrote:
Dear Jacob,
> begin
> readln(asc_file,buffer);
> inc(cell_count);
> strPcopy(file_array,buffer);
This just doesn't make any sense, you probably left out parts from the
source you sent to the list. For instance, you are not writing to any file,
only to the standard output. You should specify the task in a little bit
more detail. If I got it right, your input file contains the actual
filenames (or some portions of those). The simplest way to spread them into
various files would be to read a line from the input file, decode the
filename to be written to, open it (with rewrite the first time, with append
later on), write into it whatever you want, then close it again.
Whether this would be fast enough, depends on the size of the input file,
the number of possible output files and the distribution of the lines in the
input file. If there are only a few AAA, AAB and similar items, you might
leave all output files open and close all of them only at the end.
If you want to have a general solution that is best suited to all kinds of
input, you should first ask the operating system how many files you can open
at a time, and keep track of the usage of all these files. When you run out
of this pool of files while reading the input, you can close the file you
used least recently and open the new file instead. Whenever you write into a
file from the pool, you have to note this usage. This involves quite a lot
of additional work, so it only pays off if you need a general solution that
is to be used frequently.
Regards,
Gabor DEAK JAHN
-------------------------------------------------------------------
Gabor DEAK JAHN -- Budapest, Hungary.
WWW: <http://www.tramontana.co.hu/>www.tramontana.co.hu
E-mail: djg at tramontana.co.hu
More information about the fpc-pascal
mailing list