Changes

Jump to navigation Jump to search
Create entire page
{{Reference
|name=dostepwiserecurse
|attributes=
}}

== [[Help:Reference|Syntax]] ==
<table cellspacing="4" cellpadding="2" class="cmd">
<tr>
<td colspan="2" class="cmd">\dostepwiserecurse<!--
--><span class="first" >{''start''}</span><!--
--><span class="first" >{''stop''}</span><!--
--><span class="first" >{''step''}</span><!--
--><span class="second" >{''commands''}</span><!--
--></td>
</tr>
<tr valign="top" class="first">
<td class="cmd">{''start''}</td>
<td>Initial value of recurselevel</td>
</tr>
<tr valign="top" class="first">
<td class="cmd">{''stop''}</td>
<td>Stop when recurselevel is higher than this (or when lower, if ''step'' is negative)</td>
</tr>
<tr valign="top" class="first">
<td class="cmd">{''step''}</td>
<td>Increment recurselevel by this much after each iteration</td>
</tr>
<tr valign="top" class="second">
<td class="cmd">{''commands''}</td>
<td>Commands or text to repeat</td>
</tr>
</table>

== Description ==

Repeat something for ''start'', ''start + step'', ''start + 2*step'', ..., continuing until ''stop'' is exceeded.

== Example ==
<context source=yes>
Counting down:
\dostepwiserecurse{10}{4}{-2}
{\recurselevel...\ }
Counting stopped.

Counting down again:
\dostepwiserecurse{10}{5}{-2}
{\recurselevel...\ }
Counting stopped.
</context>

== See also ==
* [[System Macros/Loops and Recursion]]
* Looping a fixed number of times
** {{cmd|dorecurse}} for iterating from 1 to n.
** {{cmd|dostepwiserecurse}} for iteration with arbitrary start, end, and step.
** {{cmd|recurselevel}} for the iteration number.
** {{cmd|recursedepth}} for the iteration depth, in the case of nested {{cmd|dorecurse}} and co.
* 'While' loops with exit conditions
** {{cmd|doloop}} for a loop that repeats until exited.
** {{cmd|exitloop}} to exit a loop.
** {{cmd|exitloopnow}} to immediately exit a loop.
** {{cmd|looplevel}} to know which iteration the loop is in.
** {{cmd|loopdepth}} to know how many nested loops deep we are.
* {{cmd|input}} is also often used to produce dummy text.
* [[Programming_in_LuaTeX#Loops_without_worrying_about_expansion|LuaTeX]] for heavier-duty looping and iterating.

== Help from ConTeXt-Mailinglist/Forum ==
All issues with:
{{Forum|{{SUBPAGENAME}}}}

[[Category:Command/Internals|dostepwiserecurse]]

Navigation menu