COUNTER
Returns a Number value
You can use the COUNTER expression to keep track of the current number of repetitions of a repeated dialog. Each time a user clicks the Next button at a repeated dialog and provides additional information, the value of COUNTER increases.
For example, a user may want to create a word processor table that contains a numbered list of clients:
«REPEAT Client Information»
«COUNTER». «Client Name»
«END REPEAT»
In the example above, Client Information repeats the Client Name variable. Each time a user enters a different client, COUNTER is incremented and merged into the assembled document. For example:
1. John TeNgaio
2. Erica Nees
3. Lisa Alvey
4. Jonathan Rainwater
HotDocs also uses COUNTER as a way to compare two incrementing number values. For example, perhaps you want to list the last child named in a repeated dialog:
""
REPEAT Children Information
ASCEND Child Birth Date
IF COUNTER = COUNT( Children Information )
RESULT + "The youngest child is " + Child Name
END IF
END REPEAT
In this computation script, HotDocs first sets the value of the computation to nothing. It then processes the REPEAT instruction, sorting the children based on their birth dates. It uses COUNTER to determine when the last answer in the dialog is given (by comparing it to the COUNT of the dialog), and then merges the name of the youngest child in the list into the document.
The difference between COUNT and COUNTER is that COUNT counts the number of repetitions in a list, while COUNTER gives you the number of the current repetition.