Tips on Naming Your Variables

How you name variables in your templates depends largely on personal preference or your project guidelines. However, there are a few rules and suggestions that can make the automation and assembly process easier.

Assign Common, Useful Names

A variable name guides the user in answering each question, so you should choose meaningful names as you design your templates. A variable name can have up to 50 characters, including letters, numbers, and some symbols. However, the first character must be a letter. Each variable name must be unique—even if the variables are different types, their names cannot be identical.

It is often useful to put the subject of the variable name first. This allows you to sort variables alphabetically and bring up the variables with the same subject together. For example using ClientName rather than Name of Client (and ClientAddress, ClientEmail etc) will allow you to see all Client variables together rather than all Name variables together.

Some developers find it useful to append a type identifier to the name. For example, Beneficiary Age CO where CO marks it as a computation variable.. Following this method allows you to quickly identify types of variables and use the same name with a different identifier for related variables.  

Do not use any words typed in all uppercase letters in your variable names. Because HotDocs instruction and expression keywords use uppercase letters, you may inadvertently use a word that may someday become a keyword, which will prevent HotDocs from reading your variable name correctly. (See Introduction: Instruction and Expression Models.)

Finally, there are certain characters you CAN NOT use when naming your components. They are:

Character Name
. Period
$ Dollar sign
" Quotation mark
: Colon
[ ] Brackets
, Comma
( ) Parenthesis
% Percent

These characters can be used only if there is a character other than a space immediately before or after it:

Character Name
+ Plus
- Hyphen
* Asterisk
/ Forward slash
> < Greater Than and Less Than signs
>= <= Greater Than or Equal To and Less Than or Equal To signs
= Equals
!= Does not equal

In addition, if you are developing templates for use with HotDocs Server, the following characters should be avoided when naming components:

Character Name
? Question mark
& Ampersand
@ At symbol

Share Answers Between Templates

If you have multiple templates that use the same information, your users can share answers across a set of templates. To do this, you must create variables with the same names in each template, and users must use the same answer file when assembling documents. (See Assemble a Text or Form Document and Create a New Answer File.) When the variable names are identical, the answers in separate documents are also identical. However, variable names are context-sensitive and any limits entered for the first variable (such as maximum number of characters, patterns, and decimal places) must be entered for each duplicate variable or the answers will not flow from one document to the next.

When many variables are shared throughout your template set, you may find it easier to use one component file for all of your templates. (See Use One Component File for Multiple Templates.) Or, if you want each template to use an independent component file, copy the contents from the first template’s component file into each subsequent component file. (See Copy Components From One File to Another.) Using either method, you can use variables you have already created, rather than recreating each variable.