[texhax] macro expansion and \input
Philip TAYLOR
P.Taylor at rhul.ac.uk
Mon Oct 1 12:38:37 CEST 2012
Neal H. Walfield wrote:
> Based on this observation, I tried to preexpand \input's argument:
>
> \documentclass{article}
>
> \begin{document}
>
> % My general-purpose macro.
> \def\mutate#1{
> \def\helper{#1}
> \helper
> }
>
> \def\myinput#1{
> \edef\filename{#1}
> \input{\filename}
> }
>
> \myinput{\mutate{23}}
>
> \end{document}
>
> But, this results in a different error:
Neal, as you do not give us any information as to exactly how
you want to mutate the filename, I cannot be certain that the
following will work, but for my simple version which just
prepends the letter "X" it seems adequate. It is based
on your \myinput, but puts /all/ of the functionality there
rather than requiring \mutate to be passed as a part of
the parameter string.
Philip Taylor
--------
\documentclass {minimal}
\begin{document}
\def \mutate #1{X#1}
\def \myinput #1%
{
\edef \filename {\mutate {#1}}%
\input {\filename}%
}
\myinput{23}}
\end{document}
More information about the texhax
mailing list