[XeTeX] \@nameuse question
Michiel Kamermans
pomax at nihongoresources.com
Fri Sep 17 12:14:54 CEST 2010
Hi all,
I'm cleaning up my ucharclasses package, and wanted to move from
ifthen/forloop to plain TeX. The Original code was:
\newcounter{iclass}
% general transition rule
\newcommand{\@transition}[3]{\XeTeXinterchartoks #1 #2=#3}
% Use: \setUTransitions{when entering this block}{when leaving this
block}
\newcommand{\setTransitionsFor}[3]{
\forloop{iclass}{\the\@classstart}{\value{iclass} <
\@nameuse{#1Class}}{
\@transition{\the\value{iclass}}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{\the\value{iclass}}{{#3}}}
\addtocounter{iclass}{2}
\forloop{iclass}{\value{iclass}}{\value{iclass} < \the\@classend}{
\@transition{\the\value{iclass}}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{\the\value{iclass}}{{#3}}}
% and a binding for the transitions to and from boundary characters
\@transition{255}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{255}{{#3}}}
This works quite well, but relies on the forloop package. I replaced the
\forloop commands with \loop<init>\if<cond><success>\repeat:
\newcommand{\setTransitionsFor}[3]{
\loop\setcounter{iclass}{\the\@classstart}
\if\value{iclass}<\@nameuse{#1Class}
\@transition{\the\value{iclass}}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{\the\value{iclass}}{{#3}}
\addtocounter{iclass}{1}
\repeat
\addtocounter{iclass}{2}
\loop\setcounter{iclass}{\value{iclass}}
\if\value{iclass}<\the\@classend
\@transition{\the\value{iclass}}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{\the\value{iclass}}{{#3}}
\addtocounter{iclass}{1}
\repeat
% and a binding for the transitions to and from boundary characters
\@transition{255}{\@nameuse{#1Class}}{{#2}}
\@transition{\@nameuse{#1Class}}{255}{{#3}}}
However, running this through xelatex tells me:
! Missing number, treated as zero.
<to be read again>
\#1
l.263 ...\value{iclass}}{\@nameuse{#1}Class}{{#2}}
?
What obvious protecting/immediate expansion/delayed expansion am I
forgetting?
- Mike "Pomax" Kamermans
nihongoresources.com
More information about the XeTeX
mailing list