[NTG-context] ! Extra \else error
Bart C. Wise
bntgcontext at wiseguysweb.com
Thu Dec 11 16:05:38 CET 2008
On Thursday 11 December 2008 07:29:15 am Zhichu Chen wrote:
> Hi Bart,
>
> On Thu, Dec 11, 2008 at 10:21 PM, Bart C. Wise
>
> <bntgcontext at wiseguysweb.com> wrote:
> > If I change the loop to be the following, I still get the same error:
> >
> > \def\myloop#1{%
> > \tempcnta=\the\startcnt%
> > \loop
> > \advance \tempcnta by 1
> > \if\tempcnta=#1\else \repeat\fi
> > }
> >
> > Bart
>
> No, you should define like:
>
> \def\myloop#1{%
> \tempcnta=\the\startcnt%
> \loop
> \advance \tempcnta by 1
> \if\tempcnta<#1\repeat
> }
>
> No \else before \repeat in this case and no \fi outside the loop.
>
> Taking a look at the definition, you could find the following
> code (something like that, I can't remember clearly):
>
> \def\loop#1\repeat{\def\body{#1}\iterate}
> \def\iterate{something to do with \body}
>
> You can see there should not be an extra \else in the \body, and
> you don't need the \fi to enclose it.
>
> I don't know whether I've made my point clear.
Chen,
Thanks. That makes sense now. However, when I take your code and run it, it
only goes through 1 iteration of the loop and exits. I'm puzzled.
Bart
More information about the ntg-context
mailing list