Am 06.06.2013 um 09:56 schrieb Jaroslav Hajtmar <hajt...@gyza.cz>:

> Hello ConTeXist.
> Is there in ConTeXt any dirty trick, which can put more than 9 parameters 
> into macro?
> 
> I mean for example \define[25]\macrowithtwentyfiveparams{ .... }

There are a few tricks when you need more then nine parameters
but it’s better to use a different method to pass argument from
one command to another. Better and more readable solutions are
intermediate commands for each value or assignment lists (a=x,b=y,…).

> I use rarely any trick from Peter Olsak (see below) and I'd like something 
> like that used in ConTeXt.
> 
> Thanx
> Jaroslav Hajtmar
> 
> Here is minimal example of trick of Petr Olsak:
> 
> \newcount\tempnum
> \def\terminator{*}
> \newcount\tempnum
> \def\readparameters{\tempnum=0\let\next=\readone \next}
> \def\readone #1,{\advance\tempnum by 1 \def\param{#1}%
>        %\the\tempnum - \param\par%
>    \ifx\param\terminator \let\next=\relax
>    \else\expandafter\gdef\csname param\the\tempnum\endcsname{#1}%
>    \fi\next}
> 
> 
> \def\moreparameters#1{%
> \readparameters #1 %
> \csname param1\endcsname, % write first parameter
> \csname param3\endcsname, % write third parameter
> \csname param5\endcsname, % write fifth parameter
> }
> 
> 
> \starttext
> 
> %\readparameters a,b,c,d,e,f,g,h,i,j,k,m,n,o,*, %
> %\def\parameters{aaa,bbbb,cccc,dddd,eeeee,fffff,ggggg,*,}
> %\expandafter\readparameters\parameters
> 
> \moreparameters{a,b,c,d,e,f,g,h,i,j,k,m,n,o,*,}
> 
> \stoptext


Can be simplified with \processcommalist:

\starttext

\def\domoreparameters#1%
  {\advance\scratchcounter\plusone
   \setvalue{param\number\scratchcounter}{#1}}

\def\moreparameters[#1]%
  {\scratchcounter\zerocount
   \processcommalist[#1]\domoreparameters}

\moreparameters[a,b,c,d,e,f,g,h,i,j,k,m,n,o]

\getvalue{param1},
\getvalue{param2},
\getvalue{param3}

\stoptext

Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the 
Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

Reply via email to