Understand and Resolve Syntax Errors in a Template or Script

When HotDocs encounters a component or instruction in a template or script that it doesn't recognize or understand, it generates and displays a syntax error message. This message lists the component or components HotDocs was processing when it encountered the error and allows you to go directly to that point in the template or script so you can fix the problem. (See Understand the HotDocs Scripting Language.)

Errors may be caused by:

  • Unrecognized variable names: Any references to variables or other components must have a corresponding component in the component file. For example, you cannot refer to the Text variable Employee Name in the template unless there is Text variable in the component file named Employee Name. This includes using unrecognized variable names in prompts, dialog element text, scripts, and so forth.
  • Incomplete instructions: IF and REPEAT instructions used in the template or a script must have corresponding END IF and END REPEAT instructions. If HotDocs cannot find these instructions, it generates a syntax error when you assemble the document. (This includes test assembling from the template development window.) (You can have HotDocs match opening instructions with closing instructions. See Match Opening Instructions with Closing Instructions.)
  • Syntax errors in a script or expression: Writing scripts in HotDocs requires you to use a specific "language" that HotDocs can recognize and then process. If you use the language incorrectly, or if you use words that are not part of the language, you will receive an error when you try to save your work.

HotDocs reports syntax errors when you try to test assemble a document and when you try to save a script that contains syntactical errors:

  • When a syntax error occurs in a template, HotDocs displays a warning message that describes the error and displays the processing stack for the error. The stack shows, starting from the bottom, the components HotDocs was processing when it found the error. The Field denotes the variable or instruction field in the template where the error occurred, while Position denotes the character position within the field or script.
  • To resolve such a syntax error, select an entry in the processing stack and click Go To Error. (Usually, you should select the topmost entry in the stack.) HotDocs takes you to the reference point so you can make the change. (When you click Go To Error, HotDocs continues to display the error message in a pop-up window, which you can leave open until you have corrected the error. When finished, click Close at the message box.)

You can click the Go to Field button in the HotDocs toolbar to quickly move to a variable or instruction field containing an error.

  • When a syntax error occurs in a script, HotDocs displays an error message and then moves the cursor as close to the error in the script as it can.

For more information on writing scripts, see Understand the HotDocs Scripting Language, Introduction: Instruction and Expression Models, and Customize a Computation Variable.