[texhax] [read this] How to make the following condition: if..., then..., else...

Philip TAYLOR P.Taylor at Rhul.Ac.Uk
Tue Oct 3 19:20:54 CEST 2006


Maybe use \openin and \ifeof to test ?

\newread \inputstream

\def \badfile {Missing.tex}
\def \goodfile {Exists.tex}

\let \inputfile = \badfile

\openin \inputstream = \inputfile \relax
\ifeof \inputstream
\else
     \closein \inputstream
     \input \inputfile
\fi

\let \inputfile = \goodfile

\openin \inputstream = \inputfile \relax
\ifeof \inputstream
\else
     \closein \inputstream
     \input \inputfile
\fi

\end

Philip Taylor
--------

H wrote:

> How can I make the following condition in a .tex (main) document: if...,
> then..., else...?
> For example, I have this:
> 
> %...
> \input{pack.tex} 
> %...
> 
> But, the problem: it never will be available. So, I pretend to use
> if..., then,... else... for no allowing LaTeX to make an error as follow
> as: 
> 
> 
> if "pack.tex" exists, then input (include) it, else ignore it
> 
> -HRE


More information about the texhax mailing list