A literal is a representation (in the HotDocs scripting language), of a specific known value; this means the literal has a certain syntax for conveying that value. For example, when you are creating a script and you want to reference a record literal, you enclose the items in a record literal in curly braces and separate the values in the record by commas, like this:
In this topic ShowHide
Among others, literals enable you to perform the following common tasks:
Types of Literals in the HotDocs Scripting Language
Every value type in the HotDocs scripting language has a corresponding literal notation that enables you to work with that type and access its value in a scripting context.
|Type of Literal
||Text literal values are strings within quotes, like this:
"This is a text literal."
||Number literal values are simply integers, as follows:
- Numbers cannot contain commas (1250 not 1,250)
- Decimal numbers less than one must have a zero before the decimal point (0.125 not .125)
||Date literal values require a day, month, year order, (abbreviating the month) as follows:
11 FEB 1964
||True/False literal values appear as:
TRUE or FALSE
Important General Considerations when Working with Literals
When using literal values in a script, to avoid errors you can either drag and drop a model into your script, or use the lookup feature. When manually typing the script:
- You must add component names exactly as they appear in the Components list (including capitalization)
- You must ensure that spaces separate the names of components and any operators
- Operators must appear exactly as they do in the Models tab, including capitalization
- Keywords, such as TRUE, FALSE, AND, END IF, and so forth, must appear in all capital letters
- If you want the computation to return a combination of text, variables, and values, you must concatenate (or join) the data with the Add ( + ) operator. Otherwise, HotDocs returns only the last piece of text, variable, or value.
Whenever you are creating a computation, you must ensure you set the RESULT type property to the appropriate value type for the computation to work.
You can also choose to set the RESULT type to NONE when defining a custom interview computation.
Important Considerations when Working with Text Literals
When you are using text literals, besides the basic rules described in the table above, there are some other important considerations:
- To add a placeholder field for a variable within a text literal, you must type the variable name within chevrons like this "«Employee Name» must wait «Number of Months» months before applying for a transfer to another department." If the variable name is not inside chevrons, HotDocs interprets the variable name (not the value of the variable as the answer when assembling a document. This requirement has an important corollary
- If you want to include a chevron in a HotDocs text template either as a part of your document text or a literal text string, you need to double the opening chevron (but not the closing chevron), so that HotDocs does not interpret the chevrons (and any text between them) as a field. The output is a single chevron, as follows: input: ««some text», output: «some text».