DITA2Go supports “while” loops, “repeat” loops, and “until” loops:
<$_while (expr)>...<$_endwhile> loops while expr is not 0 (zero) <$_repeat (expr)>...<$_endrepeat> loops for the count of expr <$_until (expr)>...<$_enduntil> loops while expr is false
For <$_while>, a runaway-prevention feature ends the loop after the maximum count specified in the following setting:
[Macros] ; WhileMax = maximum count for <$_while>, to prevent runaways; the ; current count can be accessed using predefined macro variable ; <$$_wcount> WhileMax=128
Predefined variable <$$_wcount> contains the loop count, starting with 1 (one).
Because “until” is really the same as “while not”, the <$_while> runaway-prevention limit also applies to <$_until> loops:
[HtmlOptions] WhileMax=128
For example, a loop controlled by <$_until (0)> goes to the WhileMax limit, unless you include an effective <$_break>. Predefined variable <$$_wcount> contains the loop count, starting with 1 (one).
For <$_repeat>, the runaway-prevention limit comes into play only if the count is set to zero:
[Macros] ; RepeatMax = maximum count for <$_repeat> when value is not given, so ; that loop continues until a <$_break condition> is met RepeatMax=128
The current loop count is held in predefined variable <$$_count>, and the down-count starting with expr is in predefined variable <$$_dcount>.
You cannot nest a <$_while> in a <$_while>, or a <$_repeat> in a <$_repeat>, in the same macro. Nor can you nest a <$_while> in an <$_until>, or an <$_until> in a <$_while>. Instead you can call another macro to run a sub-loop. However, you can nest a <$_while> in a <$_repeat>, or a <$_repeat> in a <$_while>, and you can use one layer of <$_if> in the mix:
<$_while (expr)> <$_if (expr)> <$_repeat (expr)>...<$_endrepeat> <$_else> <$_repeat (expr)>...<$_endrepeat> <$_endif> <$_endwhile>
You can use <$_break> to skip to the end of the loop, and <$_continue> to jump back to the start of the next iteration. Although you can invoke these control elements in <$_if>s, it is simpler to use the following constructs:
<$_break if (expr)> <$_continue if (expr)>
Use only a single space before each if, and a minimum of one space after each if. These constructs work even in nested <$_while> or <$_repeat> loops, where they apply to the innermost of the loops where they occur.