This line type is used to set or change the value of a variable. It begins with a =
character to represent an assignment, and is followed by a variable name, and then another = to represent assigning the variable to the remainder of the line. An assignment line is not added to the final output.
The language has three possible variable types:
true/false | also known as boolean | can be set by a question prompt, or var assignment |
number |
negative or positive non-floating-point numbers possible range +/- 2 billion |
can be set by a select or number prompt, or var assignment |
text | text string | can be set by a text prompt, or var assignment |
A variable can be re-defined by an assignment any number of times, but it cannot be re-defined as a different type. The variable name (between the =
characters) will be assigned to the result of the rest of the line, which can be a simple assignment or a more complex expression as shown in the examples below.
An assignment may contain 1 or 2 operands. An operand can be either a constant value such as a number, text string, or a true/false value. It can also be a variable name. When 2 operands are present, both cannot be constants. The following operators are supported between 2 operands:
Operators, types they can work with, and result type |
|||||
can use with → |
number |
true/false |
text |
result type: | |
|
add |
× |
|
|
number |
|
subtract |
× |
|
|
number |
|
multiply |
× |
|
|
number |
|
divide |
× |
|
|
number |
|
less than |
× |
|
|
true/false |
|
greater than |
× |
|
|
true/false |
|
equality test |
× |
× |
× |
true/false |
|
non-equality test |
× |
× |
× |
true/false |
|
and |
|
× |
|
true/false |
|
or |
|
× |
|
true/false |
|
negate the operand* |
|
× |
|
true/false |
*The ! character is the only one that can be used with both 1 or 2 operands
Examples |
|
= varOne = -33 |
Set variable to a number value |
= varOne = true |
Set variable to a true/false value |
= varOne = varTwo |
Copy the value from one variable and assign to another |
= varOne = !varTwo |
Negate value of a variable and assign the true/false result. |
= varOne = "Description" |
Assign a text string |
= varOne = "A Label and $varOne" |
Example of assigning text while also substituting a text variable See the Text Substitution page for more detail |
|
Assign true if both operands are equal. Operands can be number or true/false. Assignment is true/false. |
= varOne = varTwo != 1 |
Same as above with == , except assign true if they are not equal. |
|
Assign true if the left operand is less than the right. Operands are of type number. Assignment is type true/false. |
= varOne = varOne > varThree |
Assign true if the left operand is greater than the right. |
|
number mathematical operations. Operands and Assignment result are of type number. |
|
Assign true if both operands are true. Operands and Assignment result are of type true/false. |
|
Assign true if either operand is true. Operands and Assignment result are of type true/false. |
An assignment that contains a variable in one or both operands is referencing the variable value(s) to determine the assignment result. This reference exposes the list to a possible variable ordering error, which is discussed in the Variable Ordering section of the syntax page.