[texhax] plain TeX: separate items by comma in \write environment
Rodolfo Medina
rodolfo.medina at gmail.com
Fri Apr 27 22:19:54 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
Fine, thanks... but how can I translate it into simple plain TeX,
i.e. processing the file with `tex test' rather than xetex...?
Rodolfo
More information about the texhax
mailing list