LIMIT Instruction
The LIMIT instruction restricts the number of iterations a template user can add to a repeated dialog.
The LIMIT instruction is only available when you are creating a dialog script in the Script tab of the Dialog Editor.
A LIMIT instruction you place in dialog script stops the template user from providing more than the allowed amount of answers to the variables on a repeated dialog. You specify the amount of allowed repetitions in the dialog script.
If you only want to control the number of viewable rows in a spreadsheet dialog, but let the template user enter as many answers as they need, you can use the Rows to display property in the Dialog Editor.
Instruction name | Model | After you drag and drop the model into the script tab: |
LIMIT | LIMIT ⟦NUM⟧ | Replace ⟦NUM⟧ with the number of repetitions the template user is allowed to complete. You can use a whole number, a Number variable, or a computation that produces a number output. |
Example
A template author creating a project information report, has two repeated dialog in their template. One gathers information on the indivdual projects and the other gathers a list of the staff members assigned to a given project. Both dialogs need to limit the amount of repeats the template user is allowed, but they need to use slightly different approaches in doing so.
The ProjectInformation dialog gathers information about the individual projects and contains:
- ProjectName – A Text variable where the template user types the project name
- StaffAmount – A Number variable where the template user types the amount of staff members needed for this project
- StaffList – A repeated child dialog which contains one Text variable, StaffName, where the template user types the names of all the staff members needed for the project
Then, on the script tab of the dialog editor of the ProjectInformation dialog you add the following script:
LIMIT 5
Now the template user will not be able to add more than five projects to the report.
Once the template user has given the amount of staff needed for a project, the template author wants to restrict the amount of staff members they can assign to that project.
In the script tab of the dialog editor for StaffList, the template author adds the following script:
LIMIT StaffAmount
Now if the template user says that only two staff members are required for the project, they can only complete two repetitions of StaffList to provide two names.
If you use a Number variable with a LIMIT instruction, make sure the template user answers Number variable before the repeated dialog.