IF EXPRESSION; ELSE IF; ELSE; END IF

PlaceholderA marker in an instruction or expression model that indicates where a value must be substituted. This value must be a literal value or a variable. Instruction and expression models help the developer use the correct syntax in a script. Replace With
EXPRESSIONA command in a script that retrieves a special value. Expressions help calculate dates, sums, and so forth. 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 instructionA command in a script or template that performs a special task, such as inserting a template or asking a dialog at a specific place in the interview. 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 testThe process of testing a variable or other component to make sure it looks right and works correctly. several conditions before applying a single effect.

For example, in the following scriptOne or more instructions and/or expressions that generate a value or execute some kind of procedure., 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 templateA word processor or form document that has been converted to HotDocs format so that it can be automated. When in template format, changeable text in the template can be replaced with variables. Other instructions can be added as well, such as instructions that create lists, condition text, and insert other templates. 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 userThe customer, client, or person who assembles documents from templates. (See also template developer.) greater control over the interviewA series of dialogs, each containing one or more questions which HotDocs generates from the variables you add to your template. The template's user must answer the questions in the interview before HotDocs can assemble a custom document. You can view the interview by clicking the Interview tab of the assembly window. The left pane of the assembly window displays an outline of the interview. As the user answers questions, the outline tracks the user's progress through 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.