Use Operators when Scripting

An operator is a symbol or word that causes an operation such as addition or a comparison to be performed in a computation or expression. Operators are available at the Operators list wherever you can create a script or expression. Most operators can be used when working with both number and text values.

There are three types of operators:

  • Comparison operators: These compare two values of the same type (text, number, date, multiple choice, or true/false). They return values of true or false depending on whether the comparison is true or not.
  • Arithmetic operators: These calculate new values. Operands used in the script must be the same type.
  • Logical operators: These return a true/false value based on a logical comparison of their operands, both of which must be true or false values.

The following tables explain how each operator works:

Comparison Operator Description
= The two items in the comparison are of equal value. For example:

Birth Date = 17 Dec 1989

Employee Name = "Louisa Gehrig"

!= The two items in the comparison are not of equal value. For example:

IF Exhibit A != TRUE

IF Plaintiff Gender != "Male"

< The first item in the comparison has a lesser value than the second item. For example:

Account Balance < 9000

COUNTER < 10

> The first item in the comparison has a greater value than the second item. For example:

Dependent Age > 18

<= The first item in the comparison is less than or equal to the second item. For example:

Client Age <= 65

COUNTER <= 2

>= The first item in the comparison is greater than or equal to the second item. For example:

Taxed Income >= 75000

CONTAINS The value of the first item is found in the value of the second item. For example:

"massachusetts virginia kentucky pennsylvania" CONTAINS State Name

Arithmetic Operator Description
+ Add the different components of the script together. For example:

Value 1 + Value 2

Street Address + ", " + City + ", " + State

- Subtract the different components of the script from each other. For example:

Monthly Income - Amount of Owed Child Support

* Multiply the different components of the script. For example:

Purchase Price * 0.625

/ Divide the different components of the script. For example:

Yearly Salary / 12

- The unary minus operator results in the numeric negation of the operand (which must be a Number value). For example:

SET Loss Amount TO - Aggregate Amount

% The unary percent operator results in the operand (which must be a Number value) divided by 100. It is a postfix operator. For example:

Purchase Price + (Purchase Price * 6.25%)

Logical Operator Description
AND The statement to the left and the statement to the right must both be true. For example:

IF Client is Married AND Client has Children

OR The statement to the left or the statement to the right must be true. For example:

IF Single OR Widowed

NOT The NOT operator results in the logical negation of the operand (which must be a True/False value). For example:

IF NOT Client is Married

HotDocs also supports two other unary operators—unary plus (+) and the dollar sign ($). While both produce numeric results in a script, the results are exactly the same as the operands. Therefore, they should not be used in a script.

The Add ( + ) operator can also be used to string together (concatenate) two text values.

The final operator, the parentheses ( ), instructs HotDocs to perform the operation inside the parentheses first.

HotDocs operators are processed in the following order of precedence, from highest to lowest. Operators listed on the same line have the same precedence.

()

NOT - %

* /

+ -

= != < > <= >=

AND

OR

So in other words, when HotDocs is evaluating an expression, first parenthesis are used to determine order of operations, then unary operators, then multiplication and division, then plus and minus, then comparisons, then logical AND, and last logical OR.

Â