[NTG-context] how to figure out the number of elements inside \defineconversion?

Mojca Miklavec mojca.miklavec.lists at gmail.com
Thu Aug 10 21:36:02 CEST 2006


On 8/10/06, Hans Hagen wrote:
> Mojca Miklavec wrote:
> > Hello,
> >
> > I would like to \defineconversion and the use that set of symbols
> > inside a metapost graphic. But I need to know the number of symbols,
> > so that I can define enough "metapost images with symbols" in advance.
> > I realise that there might be a problem since conversion can sometimes
> > take an arbitrary number (using a command defined elsewhere), but if I
> > could have a reasonable guess for conversions defined explicitely,
> > that would already help a lot. (As a workaround and/or if there is no
> > easy method to figure that out I can still hardcode "25" and wait
> > until someone complains that that is not enough to satisfy his/her
> > needs.)

> \unprotect
>
> \def\doifelseconversionnumber#1#2%
>   {\doifdefinedelse{\??cv#1#2}}
>
> \protect
>
> \defineconversion[abc][$\star$,$\bullet$,$\ast$]
> \defineconversion[def][m,o,j,c,a]
>
> \doloop
>   {\doifelseconversionnumber{abc}{\recurselevel}
>      {[abc \recurselevel\space defined]}
>      {\exitloop}}
>
> \doloop
>   {\doifelseconversionnumber{def}{\recurselevel}
>      {[def \recurselevel\space defined]}
>      {\exitloop}}

Perfect. That's exactly what I needed. I only have to keep my fingers
crossed now (I haven't tested the executable for a while) ...

Mojca


More information about the ntg-context mailing list