Tips on Using IF Instructions
How HotDocs Processes IF Instructions and Expressions
HotDocs processes IF instructions by starting at the top of the IF instruction and looking for the first condition that is true. Once it finds a true condition, it inserts the correct text and continues processing any additional instructions. But if all the conditions are false, HotDocs doesn’t insert anything at all (unless there is an ELSE instruction). When the True/False variable or expression that controls the IF instruction is not answered or satisfied, none of the instructions are processed and no text is merged in the document.
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.
Line Spacing
The key to correct line spacing between paragraphs when one or more paragraphs is conditional is understanding the process by which HotDocs inserts returns. By default, HotDocs inserts a return after each IF instruction. Then, during assembly, it removes any returns it has inserted.
You can select an option that inserts returns after every instruction, an option that inserts returns only if a complete paragraph is selected, or an option that doesn't insert any returns at all. (See Control When Returns Are Inserted After Instructions in Text Templates.) If you opt to include returns after complete paragraphs, if there are blank lines between paragraphs, be sure to consistently include either the preceding or following blank line.
Qualifying Instructions
When automating a template, you can cause certain things to happen in your interview based on answers a user gives. You accomplish this by using IF instructions. When using IF instructions, however, you should never reference a conditional variable outside the context of its full condition.
For example, the following script only asks Text Variable B if True/False Variable A has been answered true. Then, later in the template, another dialog is asked based on whether Text Variable B has been answered.
«IF True/False Variable A»
«Text Variable B»
«END IF»
…
«IF ANSWERED( Text Variable B)»
«ASK Dialog 1»
«END IF»
However, this script is incorrect since a user can reassemble the document (using the same answer file) and change the answer for True/False Variable A. This would keep Text Variable B from being asked again. However, a value still exists for Text Variable B in the answer file, so when HotDocs reaches the IF expression later in the template, Dialog 1 is asked.
To fully qualify this condition, create an IF expression that tests both True/False Variable A and Text Variable B before asking Dialog 1. For example:
«IF True/False Variable A AND ANSWERED (Text Variable B)»
«ASK Dialog 1»
«END IF»