I don't know too much about writing and reading to and from files. But I managed to create a nice command for me where I need to write something into a text-file and later-on read it again.
\newcommand{\customwrite}[1]{
\newwrite\tempfile%
\immediate\openout\tempfile=filename_#1.txt%
\immediate\write\tempfile{\the\figheight}%
\immediate\closeout\tempfile%
}
The reading is achieved by
\newcommand{\customread}[1]{
\newread\tempfile%
\openin\tempfile=filename_#1.txt%
\read\tempfile to \fileline%
\setlength\figheightex\fileline%
\closein\tempfile%
}
Both things works fine for me as long as I have not too much of this calls.
Recently, I had a bigger document and everything failed and I got the message No room for a new \write
. I searched for this error and what I found is, Latex is only capable of opening 16 write and 16 read streams. Apparently \closeout
and \closein
don't actually close these streams what I thought.
My question is now: is it somehow possible to actually close these streams?
\tempfile
repeatedly, without more than one\newwrite
. Or am I missing something? And you shloud have a seperate one\mytempout
for writing and\mytempin
for reading...\tempfile
repeatedly. I only need this "variable" once while executing the command. and since I always only execute one of the commands, it was working for me using the same "variable"\tempfile
for writing and reading\new....
out of the definitions and just execute them once in the preamble.