ELSE Instruction

The ELSE instruction adds a branch to an existing conditional region which HotDocs only processes if the preceding IF/ELSE IF conditions are false.

The ELSE Instruction is available when you are creating a script in the Component Studio or from the Field Editor in a template.

You can only use an ELSE instruction between an IF instruction and an END IF instruction. It must come after any ELSE IF instructions.

Once you make a region of the template or script conditional using an IF instruction, (and optionally create alternative conditional regions using the ELSE IF instruction) you can choose to create a final conditional region to account for the possibility that the preceding condition (or conditions) evaluates to false. If the condition in the IF instruction evaluates to false, HotDocs then looks to see if there is an ELSE IF instruction containing an alternative condition. Once HotDocs processes any ELSE IF instructions, and if none evaluate to true, it looks for an ELSE instruction and processes the conditional region directly below the ELSE instruction.

You cannot add any further conditional regions once you add an ELSE instruction. You must close this conditional region with an END IF instruction.

Instruction name Model After you drag and drop the model into the script tab:
ELSE ELSE You don't need to do anything further with this model.

Example

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

Download

After you download the example template, you can import the template to any workspace to see this example code in action.