When it comes to REPEATS in HotDocs, LIMIT is one very handy instruction to know how to use. As its name suggests, it will LIMIT the number of iterations a repeat can hold, by placing the instruction in the dialog script of the dialog you wish to limit. Please note that this is entirely different to the number of rows shown on a repeating spreadsheet dialog. LIMIT will restrict a dialog to have only (for example) 3 iterations, where as the rows shown command will allow a repeat to hold countless iterations, but only show a specified number.
The most basic use of LIMIT is to provide a fixed number, such as:
This doesn’t really help you much, unless you are certain your dialog is only ever going to repeat 3 times only. Here, we can introduce the concept of a user-specified LIMIT. Lets say we have a dialog named Child DLG that collects some general information about all the kids, as well as a variable named CHLD CNT – asking the user how many children there are. On Child DLG is a repeating sub-dialog Children RPT – it will repeat once for each child. In the dialog script of Children RPT, we could have
LIMIT CHLD CNT
This is better – we ask them how many kids, then LIMIT the repeating dialog to that number. This will stop “empty” repeats in our templates where users have clicked forward and answered a field accidentally. Great. Lets make it a bit easier to use. Instead of CHLD CNT as a number variable, lets use CHLD Num MC as a multiple choice variable, with options from 1 to 20.
LIMIT INTEGER ( CHLD Num MC )
Now, our user can click the number of kids from a list and our LIMIT instruction converts the multiple choice value to a number value. Simple, straight forward and user friendly.
The above technique can also be used to dynamically show more rows on repeating spreadsheet dialog dynamically