The XpressDox ScriptIf function
First, read through the article on Scripts to familiarize yourself with that feature.
Using a condition inside a parameterized script requires the use of ScriptIf rather than If. The matching End for a ScriptIf, is a ScriptIfEnd().
It is worth copying-and-pasting this example into a template and trying it out. Note that in the example, the Required and second Rule commands are generated conditionally using the ScriptIf.
Script(LimitRepeaters,RepeaterName,RepeaterDescription,MinimumNumber,MaximumNumber,FirstRepeaterElement)»
«Comment(This is a kind of generic “Limit the number of repeaters”, at the same time parameterising whether there is a minimum number.)»
«Rule(&RepeaterName&,hard,count(&RepeaterName&) <= &MaximumNumber&, ‘No more than &MaximumNumber& &RepeaterDescription& are allowed.’)»
«ScriptIf(&MinimumNumber& > 0)»
«Required(&RepeaterName&)»
«ScriptIf(&MinimumNumber& > 1)»
«Rule(&RepeaterName&,hard,count(&RepeaterName&) >= &MinimumNumber&, ‘You need at least &MinimumNumber& &RepeaterDescription&’)»
«ScriptIfEnd()»
«ScriptIfEnd()»
«OnEnterSet(&RepeaterName&/&FirstRepeaterElement&,&FirstRepeaterElement&,Value,(PositionOfRepeater() > &MaximumNumber&),'No! Do not enter more than &MaximumNumber& &RepeaterDescription&.')»
«ScriptEnd()»