IF EXPRESSION; ELSE IF; ELSE; END IF
Placeholder | Replace With |
EXPRESSION | A statement that can be evaluated as true or false |
You can make sections of templates or scripts conditional by using IF instructions. A conditional section will be included only if a condition you specify is true. The ELSE IF instruction allows two or more conditions to be included in an IF instruction. The ELSE instruction establishes a final condition for an IF instruction, specifying that if all preceding conditions are false, the following information should be included. It must be the last item of the IF instruction.
Each IF instruction or expression must end with an END IF instruction. This instruction completes a section of conditional logic. HotDocs automatically creates an END IF paired with each IF instruction. These pairs can be nested, allowing you to test several conditions before applying a single effect.
For example, in the following script , HotDocs uses an IF instruction to insert a paragraph about vacation time—but only if the new employee qualifies for paid vacation:
«IF Vacation Days»In addition, «Employee Name» shall be allowed «Number of Vacation Days:ten» for vacation time.
«Employee Name» shall also receive seven paid holidays, including New Year's Day, Memorial Day, Fourth of July, Labor Day, Thanksgiving (including the day after), and Christmas.«END IF»
More complex situations can also be handled using IF expressions. For example, in the following computation script, a single paragraph in a template may change depending on how close a project is to completion. Using the IF, ELSE IF, and ELSE instructions, the correct paragraph can be inserted:
IF Project Status = "Complete"
"Upon finishing the project…"
ELSE IF Project Status = "In Process"
"While working on the project…"
ELSE
"Before working on the project…"
END IF
You can use IF expressions anywhere. Operators such as AND and OR can link multiple conditions, giving the user greater control over the interview . However, creating complicated IF instructions directly in the template can make the assembly process sluggish. Consider using Computation variables or INSERT instructions instead.
In past versions of HotDocs, using END by itself instead of the complete END IF instruction was sufficient. Beginning with 11.1, HotDocs no longer processes the shortened version, and now requires the complete instruction.
Please see Introduction: Make Parts of Templates Conditional for further information on using IF instructions and expressions.