Difference between revisions of "Command/recursedepth"

From ConTeXt wiki
Jump to navigationJump to search
(Create entire page)
 
(looplevel --> recurselevel; ditto -depth; adjust example correspondingly.)
Line 14: Line 14:
 
== Description ==  
 
== Description ==  
  
The nesting depth in the case of nested {{cmd|dorecurse}} or
+
The nesting depth in the case of nested {{cmd|dorecurse}},
{{cmd|dostepwiserecurse}}
+
{{cmd|dostepwiserecurse}}, and {{cmd|doloop}}.
  
 
== Example ==
 
== Example ==
 
<context source=yes>
 
<context source=yes>
\dorecurse{2}
+
\dorecurse{2}{
  {\recursedepth.\recurselevel:
+
    \recursedepth.\recurselevel:\crlf
     \dorecurse{3}
+
     ---\dorecurse{3}
 
         {\recursedepth.\recurselevel\ }
 
         {\recursedepth.\recurselevel\ }
     \crlf}
+
     \crlf
 +
    ---\doloop
 +
      {\recursedepth.\recurselevel\
 +
        \ifnum \recurselevel=2 \exitloop \fi}
 +
    \crlf
 +
}
 
</context>
 
</context>
  
Line 37: Line 42:
 
** {{cmd|exitloop}} to exit a loop.
 
** {{cmd|exitloop}} to exit a loop.
 
** {{cmd|exitloopnow}} to immediately exit a loop.
 
** {{cmd|exitloopnow}} to immediately exit a loop.
** {{cmd|looplevel}} to know which iteration the loop is in.
+
** {{cmd|recurselevel}} to know which iteration the loop is in.
** {{cmd|loopdepth}} to know how many nested loops deep we are.
+
** {{cmd|recursedepth}} to know how many nested loops deep we are.
 
* {{cmd|input}} is also often used to produce dummy text.
 
* {{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.
 
* [[Programming_in_LuaTeX#Loops_without_worrying_about_expansion|LuaTeX]] for heavier-duty looping and iterating.

Revision as of 10:07, 14 June 2012

\recursedepth

Syntax

\recursedepth

Description

The nesting depth in the case of nested \dorecurse, \dostepwiserecurse, and \doloop.

Example

\dorecurse{2}{
    \recursedepth.\recurselevel:\crlf
    ---\dorecurse{3}
        {\recursedepth.\recurselevel\ }
    \crlf
    ---\doloop
       {\recursedepth.\recurselevel\ 
        \ifnum \recurselevel=2 \exitloop \fi}
    \crlf
}

See also

Help from ConTeXt-Mailinglist/Forum

All issues with: