 # Operators Overview

An operator is a symbol or word that causes HotDocs to carry out an operation (such as addition) or a comparison (such as greater than) in a computation or expression. For example, you can use the + operator to add a known value (65) to an unknown value (Birth Year) like this: Birth Year + 65.

## Overview

At its root, an operator is a kind of function, in that an operator makes a calculation based on zero or more inputs, just as a function makes a calculation based on zero or more parameters. On the other hand, operators can also appear somewhat similar to an instruction, in that they may perform an action on a given item. In the case of an operator, the item on which they work is called an operand. An example of an operator and its input and operand is the = operator as it is used in the TEXT = TEXT calculation. In this case, the first text value is the input to the = operator, while the second text value is the operand which the = operator inspects to determine if it is the same value as the input value.

There are three types of operators:

• Comparison operators: These compare two values of the same type (text, number, date, 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 inputs and operands.

You can use these three types of operators to work with text, date, logical (true, false, greater than, equal to, etc.), and mathematical values.

Among others, operators enable you to perform the following common tasks:

## Workflow

When you write a script, in either a computation or a dialog (or wherever you create any expression), you can either type your operators by hand, or you can drag and drop the appropriate model onto the Script tab from the appropriate section of the models list on the Models tab. Using the latter method is useful, because it teaches you the syntax HotDocs expects for each operator when working with the available input and operand types.

## Comparison Operators

The following table explains how each comparison 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 Operators

The following table explains how each Arithmetic operator works:

 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

The following table explains how each Logical operator works:

 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, a parenthesis first determines the order of operations, then unary operators, then multiplication and division, then plus and minus, then comparisons, then logical AND, and last logical OR operators.

## Common Reference Topics

Among others, the following reference topics relate to this conceptual area: