HotDocs Author WorkflowCreate a template Add placeholders Group variables in dialogs Upload a template Create a script

Literals

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:

{"John Smith", 5, 10 June 1945, True}.

Common Tasks

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 Syntax
Text literals You express a Text literal as a string of characters within quotes, like this: "This is a text literal." For more information on working with Text literals, see Important Considerations when Working with Text Literals, below.
Number literals You express a Number literal using only digits, and can include a decimal point, as follows: 7 1.25 0.75

In addition:

  • 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 literals You express a Date literal in day, month, year order, (abbreviating the month) as follows: 11 FEB 1964
True/False literals You express a True/False literal as: TRUE or FALSE
Record literals

A Record literal value begins and ends with curly braces, and its values are comma separated as follows:  

{Name: "John", Birth: 5 JAN 1984, Children: 5}

A Record literal also displays the syntax of the type of the value of the data it stores. For example, the name in quotes in the example above tells you that the Name: field is a text value, while the digit without quotes in the forgoing Record literal tells you that the Children: field contains a Number value expressed as a literal. When comparing two Record literals, the order of the fields in the two Records is not important, as long as the types and values for each field match one another.

List literals

A List literal begins and ends with square brackets, and the values in the list are comma separated as follows:

  • Text list: ["John", "Mary"]
  • Number list: [5, 2]
  • Date list: [5 JAN 1984, 22 SEP 1990]
  • True/False list: [TRUE, FALSE]

A List literal also displays the literal syntax for the value types it expresses. For example, the quotes in the forgoing List syntax tells you that it contains a list of Text values. When comparing one List literal to another, order matters.

Record List literals

A Record List literal represents a list of Record values and combines the formats of List literals and Record literals in that the brackets of the List literal enclose the curly braces of the Record literal as follows:

 [{Name: "John", Birth: 5 JAN 1984, Children: 5}, {Name: "Mary", Birth: 22 SEP 1990, Children: 2}]

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 part of the text literal in quotations when assembling a document. This requirement has an important corollary:
  • If you want to include chevrons (which represents quotations in some non-English languages) in a HotDocs text template either as a part of your document text or as a text literal, 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».
  • The same principle works for escaping double quotes. Since a double quote is what starts a text literal, if you want to include a quotation within a text literal, you need to double the initial and ending quotes, as follows: "Here is a ""Text literal"" that includes quote marks."
  • If you want to add a line break within a text literal, you can accomplish this by typing the characters \r, as follows: "This is line one\rthis is line two"
  • If you want to add a tab within a Text literal, you can accomplish this by typing the characters \t, as follows: "This line contains a tab right here \t so you can separate this text from what goes before"