HotDocs Models: counter

HotDocs 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. You could create the following computation script:

""

repeat ChildrenInformation

ascend ChildBirthDate

if counter = count( ChildrenInformation )

result + "The youngest child is " + ChildName

endIf

endRepeat

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.