[Tex/LaTex] No room for a new \read/\write

external filesmemory

I've already searched a lot about it and there seems to be no possible way of increasing the number of files (La)TeX can open. This for example, gives an explanation about the error message. I've also seen some solutions for this problem, but all were specifically for graphics instead of files.

So basically, I want to open several files, currently in total possibly more than 16 (which is the current limit), and together with some packages that also use some slots. There should be at least 2 possible solutions for me:

  1. Increase the amount of files that can be opened at the same time. This however is an inefficient way of doing things.
  2. Closing and removing the file completely out of the register. I noticed that using the command \closein or \closeout does not free up space in the register. Opening a new one will still fill the next slot instead of overwriting the closed ones. For me, a max of 2 files are open at once. (I use the package datatool though, that possibly uses at least one slot too)

If anyone has an idea how to implement one of these solutions?


EDIT: Also, the first source mentioned something about e-TeX, Omega and LuaTeX. What are those and how do they help? I tried searching for them too, but I don't seem to understand if they are extensions of TeX or whole new languages. Someone also mentioned something about ConTeXt which seems to be an editor instead of language, according to Google, for Java and C++ etc.

Best Answer

The following shows 50 files being written from plain TeX:

\newwrite\foo

\count0=0
\loop
\advance\count0 by 1
\immediate\openout\foo=file-\the\count0
\immediate\write\foo{this is \the\count0}
\immediate\closeout\foo
\ifnum\count0<50
\repeat

\bye

$ tex write50
This is TeX, Version 3.1415926 (TeX Live 2012)
(./write50.tex )
No pages of output.
Transcript written on write50.log.



davidc@malta /c/tmp
$ ls file-*
file-1.tex   file-18.tex  file-26.tex  file-34.tex  file-42.tex  file-50.tex
file-10.tex  file-19.tex  file-27.tex  file-35.tex  file-43.tex  file-6.tex
file-11.tex  file-2.tex   file-28.tex  file-36.tex  file-44.tex  file-7.tex
file-12.tex  file-20.tex  file-29.tex  file-37.tex  file-45.tex  file-8.tex
file-13.tex  file-21.tex  file-3.tex   file-38.tex  file-46.tex  file-9.tex
file-14.tex  file-22.tex  file-30.tex  file-39.tex  file-47.tex
file-15.tex  file-23.tex  file-31.tex  file-4.tex   file-48.tex
file-16.tex  file-24.tex  file-32.tex  file-40.tex  file-49.tex
file-17.tex  file-25.tex  file-33.tex  file-41.tex  file-5.tex

davidc@malta /c/tmp
$ cat file-1.tex
this is 1
Related Question