You can increase or decrease named numerical counters with counterUp() and
counterDown(), respectively. The counter starts at 0 and is incremented by 1.
Use the general-purpose service format() to format the number of digits in the
output integers.
Example
In this example, the counter named i is used to number the rows of a table.
The counter output is formatted to be a two-digit number.
| Number | Name | Description |
{m:for req | requirements}
{m:'i'.counterUp.format('00')} | {m:req.name} | {m:req.description} |
{m:endfor}
This outputs the following table:
| 01 | requirement1 | Description of requirement1. |
| 02 | requirement2 | Description of requirement2. |
| 03 | requirement3 | Description of requirement3. |
To increase or decrease numerical counters with an integer other than 1, use the
counterAdd() method. To count down instead of up, use a negative integer. To
initialize or reset the counter, use counterSet(). You can initialize the counter
with any integer. As before, use format() to format the number of digits in the
output integers.
Example
In this example, the counter starts at 30 and is incremented by -5. The counter output is formatted to be a three-digit number.
| Number | Name | Description |
{m:let c='i'.counterSet(30)}
{m:for req | requirements}
{m:'i'.counterAdd(-5).format('000')} | {m:req.name} | {m:req.description} |
{m:endfor}
{m:endlet}
This outputs the following table:
| 025 | requirement1 | Description of requirement1. |
| 020 | requirement2 | Description of requirement2. |
| 015 | requirement3 | Description of requirement3. |