Changes

Jump to navigation Jump to search
m
Text replacement - "</cmd>" to "}}"
< '''Prev:''' [[System Macros/Branches and Decisions|Brances Branches & Decisions]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Action Processing|Action Processing]] >
TeX does not offer us powerfull powerful for-loop mechanisms. On
the other hand its recursion engine is quite unique. We
therefore identify the for-looping macros by this method.
number.
=== <{{cmd>|dorecurse</cmd> }} ===
<texcode>
\dorecurse {n} {whatever we want}
=== <{{cmd>|dostepwiserecurse</cmd> }} ===
The simple command <code>\dorecurse</code> is
a special case of the more general:
</texcode>
=== <{{cmd>|doloop</}} {{cmd> <cmd>|exitloop</cmd> }} ===
Sometimes loops are not determined by counters, but by
(a combinations of) conditions. We therefore implement a
straightforward loop, which can only be left when we
explictly explicitly exit it. Nesting is supported. First we present
a more extensive alternative.
</texcode>
When needed, one can call for <code>\looplevelrecurselevel</code> and<code>\loopdepthrecursedepth</code>.
The loop is executed at least once, so beware of situations
for conditional errors.
=== Recursion and expansion === Using recursion to build tables requires some particular attention: <context source="yes">\bTABLE\bTR\dorecurse{8}{\expanded{\bTD\recurselevel\eTD}}\eTR\eTABLE</context> Multi-dimensional tables offer another illustration: <context source="yes">\bTABLE\dorecurse{8}{ \bTR \dorecurse{5}{\bTD #1,##1 \eTD} \eTR}\eTABLE</context> Alternatively, (mkiv only?) <context source="yes">\bTABLE \dorecurse{8}{\bTR \dorecurse{5}{\bTD \currentTABLErow,\currentTABLEcolumn \eTD} \eTR}\eTABLE</context> For further discussion on loops and expansion, see [[System_Macros/Expansion_Control|Expansion control]] as well as this [http://randomdeterminism.wordpress.com/2009/03/05/tex-programming-the-past-the-present-and-the-future/ blog post]. < '''Prev:''' [[System Macros/Branches and Decisions|Branches & Decisions]] | '''Top:''' [[System Macros]] | '''Next:''' [[System Macros/Action Processing|Action Processing]] > [[Category:ConTeXt programmingProgramming and Databases]][[Category:Inside ConTeXtTools]]

Navigation menu