[texhax] (no subject)
Philip TAYLOR
P.Taylor at Rhul.Ac.Uk
Sun Jul 9 20:24:22 CEST 2006
Zalman Rubinstein wrote:
> Dear Sirs,
>
> I am a TUG member and have a technical question in Plain TeX programming.
OK, after clarification from Alex Scorpan, here is what
I think you want :
% Split-XY.tex
\input XY-Preamble
\newtoks \t
\newtoks \xpart
\newtoks \ypart
\newtoks \leftpart
\newtoks \rightpart
\newif \ifmoretodo
\t={ab...xy.....cd....xy....ef....xy....}
Original text : \the \t
\t = \expandafter {\the \t xy} % append a sentinel
\def \Split #1 on #2#3
{\def \parse ##1#2#3##2\sentinel
{\leftpart = {##1}%
\rightpart = {##2}%
}%
\def \pivot {#2#3}%
\parse #1\sentinel
Whole : [#1]\endgraf
Left part : [\the \leftpart]\endgraf
Right part : [\the \rightpart]\endgraf
\edef \head {\the \leftpart}
\edef \tail {\the \rightpart}
\xpart = \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter {\expandafter \expandafter \expandafter \the \expandafter \xpart \the \leftpart}%
\ypart = \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter \expandafter {\expandafter \expandafter \expandafter \the \expandafter \ypart \the \leftpart}%
\ifx \tail \empty
\moretodofalse
More to do : false\endgraf
\else
\xpart = \expandafter {\the \xpart #2}
\ypart = \expandafter {\the \ypart #3}
\moretodotrue
More to do : true\endgraf
\fi
X part : \the \xpart \endgraf
Y part : \the \ypart \endgraf
}
\count 255 = 0
\loop
\advance \count 255 by 1
\expandafter \expandafter \expandafter \Split \expandafter {\the \t} on xy
\ifnum \count 255 > 255 \moretodofalse \fi % catch runaways
\ifmoretodo
\t = \rightpart
\repeat
\end
More information about the texhax
mailing list