[NTG-context] serial definition

Peter Rolf indiego at gmx.net
Mon Jan 2 19:20:01 CET 2006


Hi ho Hraban,

Henning Hraban Ramm wrote:
> Hi ho!
> 
> This is a part of Holger Schöner's letter style (see
> http://wiki.contextgarden.net/Letter_style):
> 
> \def\lettersenderkeyone{}
> \def\lettersendervalone{}
> \def\lettersenderkeytwo{}
> \def\lettersendervaltwo{}
> % etc.
> \def\lettersenderkeynine{}
> \def\lettersendervalnine{}
> 
> \def\senderone#1#2{\def\lettersenderkeyone{#1}\def\lettersendervalone{#2}}
> \def\sendertwo#1#2{\def\lettersenderkeytwo{#1}\def\lettersendervaltwo{#2}}
> % etc.
> \def\sendernine#1#2{\def\lettersenderkeynine{#1}\def\lettersendervalnine{#2}}
> 
> 
> \startsetups sendertablesetup
>     \bTABLE
>     \setupTABLE[frame=off]
>     \setupTABLE[x][1][width=\senderkeywidth, align=left,
> style={\keystyle\strut}]
>     \setupTABLE[x][2][width=\sendervalwidth, align=right,
> style={\valstyle\strut}]
>     \bTR\bTD\doiftextelse{\lettersenderkeyone}   
> {\lettersenderkeyone:}{}\eTD\bTD\lettersendervalone\eTD\eTR
>     \bTR\bTD\doiftextelse{\lettersenderkeytwo}   
> {\lettersenderkeytwo:}{}\eTD\bTD\lettersendervaltwo\eTD\eTR
>     % etc.
>     \bTR\bTD\doiftextelse{\lettersenderkeynine}   
> {\lettersenderkeynine:}{}\eTD\bTD\lettersendervalnine \eTD\eTR
>     \eTABLE
> \stopsetups
> 
> Is there a more programmatical way for such? (Does TeX know something
> like arrays or dicts?)
> Sorry, I still can't program in TeX...
> 
Welcome to the club ;)

You can use \newcounter for such stuff or the context recurse functions
(with \recurselevel).


\starttext

\dostepwiserecurse{1}{9}{1}{% count from 1 to 9, step 1
  \setvalue{PREFIX\recurselevel}{\recurselevel}
}

% or all by hand (not useful for simple loops)
\newcounter\Row % Row=0
\increment\Row % Row+=1
\doloop{%
  \setvariables[PREFIX\Row][foo=foo\Row]
  \increment\Row
  \ifnum\Row>9 \exitloop\fi
}

% reset to one by hand
\newcounter\Row
\increment\Row

\dostepwiserecurse{1}{9}{1}{%
  \getvariable{PREFIX\Row}{foo}=
  \getvalue{PREFIX\recurselevel}\crlf
  \increment\Row
}

\stoptext


You can combine x counters to simulate a x-dimensional array (but you
better wait for lua). Hope that helps.

Greetings, Peter


> 
> Grüßlis vom Hraban!
> ---
> http://www.fiee.net/texnique/
> http://contextgarden.net
> http://www.cacert.org (I'm an assurer)
> 
> _______________________________________________
> ntg-context mailing list
> ntg-context at ntg.nl
> http://www.ntg.nl/mailman/listinfo/ntg-context
> 
> 



More information about the ntg-context mailing list