The RepeatCounter
We mentioned above that the variable NumberCompanies is referred to as the repeat generator. You can refer to the specific iteration within the repeat span using the keyword
RepeatCounter
.
For example, to index the companies:
[
Repeat NumberCompanies
Company #{
RepeatCounter
}: {CompanyName} has {NumberDirectors} directors]
giving us the following in the generated document:
Company #1: ABC Corp has 5 directors
Company #2: Real Enterprises has 3 directors
Company #3: My Company Plc has 12 directors
Company #4: Corboda Inc has 7 directors
Company #5: XYZ.com has 3 directors
Although most repeat spans are generated by number values, sometimes they are generated by a list of multi-choice options (see
Working with repeating spans - an extended example). For this reason the
RepeatCounter
itself is always a text value. It can be converted from a text value to a whole number value using the function
ToInteger
, which can then be formatted like any other number:
[
Repeat NumberCompanies
Our {
ToInteger
(
RepeatCounter
) Format "wth" lower} company, {CompanyName}, has {NumberDirectors} directors]
and the generated document now looks like this:
Our first company, ABC Corp, has 5 directors
Our second company, Real Enterprises, has 3 directors
Our third company, My Company Plc, has 12 directors
Our fourth company, Corboda Inc, has 7 directors
Our fifth company, XYZ.com, has 3 directors