[texhax] plain TeX: separate items by comma in \write environment

Rodolfo Medina rodolfo.medina at gmail.com
Wed May 2 21:25:40 CEST 2018


"Philip Taylor (RHUoL)" <P.Taylor at Rhul.Ac.Uk> writes:

> Rodolfo Medina wrote:
>> Now, what I want is to avoid duplicate
>> entries: i.e., when two or more identical entries are present, just one be
>> written down.  Please, how can I achieve that...?
> Oh, that's an easy one :-)
>
> \input eplain
>
> \newwrite \standout
> \openout \standout = temp.txt
>
> \newtoks \temptoks
>
> \def \write #1#2%
>     {%
>         \if \relax \the \temptoks  \relax
>             \temptoks  = {#2}%
>         \else
>             \ifcsname dict:#2\endcsname
>             \else
>                 \temptoks  = \expandafter {\the \temptoks , #2}%
>         \fi
>         \fi
>      \expandafter \let \csname dict:#2\endcsname = \relax
>     }
>
> \def \donewriting #1{\primitive \write #1 {\the \temptoks}\closeout #1}
>
> \write \standout {Now}
> \write \standout {Now}
> \write \standout {is}
> \write \standout {is}
> \write \standout {is}
> \write \standout {the}
> \write \standout {time}
> \write \standout {for}
> \write \standout {all}
> \write \standout {all}
> \write \standout {good}
> \write \standout {men}
> \write \standout {etc.}
> \write \standout {etc.}
>
> \donewriting \standout
> \leavevmode \vfill \eject
> \input temp.txt
>
> \end


Hi, Philip...  hi all.

If, in place of `Now', `is' etc, I put some accented name, e.g. \'Erik Satie, I
get error: system complains that no accent is allowed to appear between \csname
and \endcsname...  Any solution...?

Thanks,

Rodolfo



More information about the texhax mailing list