The & operator compares two values with a bitwise AND function. You use the & operator with two operands, like this:
Evaluate a & b
Each of the operands a and b is converted to a binary number, and each of their bits is compared; that is, bit 1 of a is compared with bit 1 of b, and so on. When two corresponding bits are both 1, bitwise AND combines them to produce 1. When one or both of the corresponding bits are 0, bitwise AND combines them to produce 0.
For example, if you enter
Evaluate 25 & 77
25 and 77 are combined with a bitwise AND, and the result is 9.
In a logical expression, the ~ operator computes the binary negative of a number. The binary negative is calculated by converting a character's 0 bits to 1 bits and its 1 bits to 0 bits.
For example, to find the binary negative of 5, you could enter
Evaluate ~5
The result of this command is -6.
The | operator compares two values with a bitwise OR function. You use the | operator with two operands, like this:
Evaluate a | b
Each of the operands a and b is converted to a binary number, and each of their bits is compared; that is, bit 1 of a is compared with bit 1 of b, and so on. When two corresponding bits are both 0, bitwise OR combines them to produce 0. When either of the corresponding bits is 1, bitwise OR combines them to produce 1.
For example, if you enter
Evaluate 25 | 77
25 and 77 are combined with a bitwise OR, and the result is 93.
The ^ operator compares two values with a bitwise XOR (that is, a bitwise exclusive OR) function. You use the ^ operator with two operands, like this:
Evaluate a ^ b
Each of the operands a and b is converted to a binary number, and each of their bits is compared; that is, bit 1 of a is compared with bit 1 of b, and so on. When one of the bits--but not both--is 1, bitwise XOR combines them to produce 1. When both bits are 0 or when both bits are 1, bitwise XOR combines them to produce 0.
For example, if you enter
Evaluate 25 ^ 77
25 and 77 are combined with a bitwise XOR, and the result is 84.
The += character is used only with the Evaluate command and adds the value on the right side of the expression to the variable on the left side. For example, in the command
Evaluate myVar += 2
the value of {myVar} is increased by 2. In the Evaluate command, you do not need to place the variable name inside braces because the command does not extract the value of the variable.
The -= character is used only with the Evaluate command and subtracts the value on the right side of the expression from the variable on the left side. For example, the command
Evaluate myVar -= 2
decreases the value of {myVar} by 2. In the Evaluate command, you do not need to place the variable name inside braces because the command does not extract the value of the variable.
The character == means "equals" when it compares text strings, arithmetic values, or variables that contain text strings or arithmetic values. If the value of the expressions are equal, the command returns 1, meaning true; if the expressions are not equal, the command returns 0, meaning false.
The command
Evaluate (3 * 4 * 27) == (6 * 9 * 3 * 2)
computes the values of each side and returns the value 1, for true. Note that arithmetic expressions use integer arithmetic. For example, the expression 5 2 yields 2, not 2.5.
The command
Evaluate {a} == 0
checks whether the current value of the variable {a} is 0 and returns 1 or 0.
When used with a text string, the match is case sensitive; for example,
Evaluate "theWorld" == "theworld"
returns 0.
The =~ operator is used with the Evaluate command to evaluate whether a text string, or a variable that contains a text string, matches a regular expression. You must place the left operand within double quotation marks and the right operand within forward slashes. For example, the following command evaluates the strings yes and no, finds that they are not the same, and displays a 0, meaning false:
Evaluate "yes" =~ /no/
You can also use the =~ character with variables, as in
Evaluate "{a}" =~ /{b}/
which compares the current values of the variables {a} and {b}. If {a} and {b} have the same value, Evaluate returns 1, meaning true. If {a} and {b} do not have the same value, Evaluate returns 0, meaning false. The command
Evaluate "{a}" =~ /$[0-9a-f]+/
checks whether the variable {a} contains a hexadecimal number. If {a} does, Evaluate returns 1. If {a} does not contain a hexadecimal number, Evaluate returns 0.
In arithmetic expressions, the > character means "greater than." You can use the > character to compare the values of numbers or variables. For example, the command
Evaluate 5 > 10
evaluates whether 5 is greater than 10 and then displays 0, meaning false, in the active window. Likewise, the command
Evaluate {a} > {b}
evaluates the current values of {a} and {b} and then displays 0 (false) or 1 (true) in the active window. If you enter the commands
Set a 4
Set b 3
Evaluate {a} > {b}
Evaluate displays 1 in the active window.
The >= character means "greater than or equal to" and has the same meaning as the ≥ character.
≥ Greater than or equal to [Option-.]
The ≥ character means "greater than or equal to" and has the same meaning as the >= character.
You can use the ≥ character to compare the values of numbers or variables. For example, the command
Evaluate 15 ≥ 10
evaluates whether 15 is greater than or equal to 10 and then displays 1 (true) in the active window. Likewise, the command
Evaluate {a} ≥ {b}
compares the current values of the variables {a} and {b}, and displays either 0 (false) or 1 (true) in the active window. If you enter the commands
Set a 100
Set b 88
Evaluate {a} ≥ {b}
Evaluate displays 1 in the active window.
In arithmetic expressions, the < character means "less than." You can use the < character to compare the values of numbers or variables. For example, the command
Evaluate 5 < 10
evaluates whether 5 is less than 10, and then displays 1, meaning true, in the active window. Likewise, the command
Evaluate {a} < {b}
evaluates the current values of the variables {a} and {b} and displays either 0 (false) or 1 (true) in the active window. If you enter the commands
Set a 7
Set b 77
Evaluate {a} < {b}
Evaluate displays 1 in the active window.
The <= character means "less than or equal to" and has the same meaning as the ≤ character.
≤ Less than or equal to [Option-,]
The ≤ character means "less than or equal to" and has the same meaning as the <= character.
You can use the ≤ character to compare the values of numbers or variables. For example, the command
Evaluate 15 ≤ 10
evaluates whether 15 is less than or equal to 10 and then displays 0, which means false, in the active window. Likewise, the command
Evaluate {a} ≤ {b}
compares the current values of the variables {a} and {b} and displays either 0 or 1 in the active window. If you enter the commands
Set a 88
Set b 100
Evaluate {a} ≤ {b}
Evaluate displays 1 in the active window.
The && operator means logical AND and has the same meaning as the AND operator.
The AND operator means logical AND and has the same meaning as the && operator.
Logical AND is based on the principle that if both sides of an expression are true (that is, not equal to 0), then the expression is true. If either side or both sides of the expression are false (that is, equal to 0), the expression is false.
For example, the command
Evaluate 2 AND 3
returns 1, or true. But the command
Evaluate 2 AND 0
returns 0. You can use the AND operator to check whether the value of a variable is 0. For example, if you enter
Evaluate {Status} AND {Value}
Evaluate returns 0 if either variable is currently set to 0.
In arithmetic expressions, the ¬ operator means logical NOT and has the same meaning as the ! operator and the NOT operator.
The ¬ operator is also used in selection expressions
In arithmetic expressions, the NOT operator means logical NOT and has the same meaning as the ¬ and ! operators. Logical NOT evaluates whether a number or variable has a value of 0. If the character or variable has a value of 0, the result of the command is 1, which means true. If the character or variable has a value other than 0, the result of the command is 0, which means false.
For example, the command
Evaluate NOT 100
displays 0 in the active window. But the command
Evaluate NOT 0
displays 1.
The || operator means logical OR and has the same meaning as the OR operator.
The OR operator means logical OR and has the same meaning as the || operator.
Logical OR is based on the principle that if either side of a statement is true (that is, not equal to 0), the statement is true. If both sides of a statement are false (that is, equal to 0), then the statement is false.
For example, the command
Evaluate 2 OR 0
returns 1, or true. However, the command
Evaluate 0 OR 0
returns 0, or false. You can use the OR operator to check whether the value of a variable is 0. For example, if you enter
Evaluate {checking} OR {savings}
Evaluate returns 0 only if the current values of both {checking} and {savings} are 0. If either {checking} or {savings} has a positive or negative value, Evaluate returns 1.
!= Not equal to (strings, numbers, and variables)
The != operator means "not equal to" and is used between two numbers or variables in an expression. The != operator has the same meaning as the <> and ≠ operators.
The <> operator means "not equal to" and is used between two numbers or variables in an expression. The <> operator has the same meaning as the ≠ and the != operators.
The ≠ operator means "not equal to" and is used between two numbers or variables in an expression. The operator has the same meaning as the != and the <> operators.
If the two sides of the expression are not equal, the command returns 1, meaning true. If the two sides are equal, the command returns 0, meaning false.
For example, the command
Evaluate 2 ≠ 5
is 1, or true. If you enter a command like
Evaluate {a} ≠ {b}
the command checks the current values of the variables {a} and {b}, determines whether they are not equal, and returns 1 for true, or 0 for false.
The !~ character is used with the Evaluate command to evaluate whether a text string or a variable that contains a text string matches a regular expression. When you use the !~ character between two operands, you must place the left operand within double quotation marks and the right operand within forward slashes. For example, the following command evaluates the strings yes and no, finds that they are not the same, and displays a 1, meaning true:
Evaluate "yes" !~ /no/
You can also use the !~ character with variables, as in
Evaluate "{a}" !~ /{b}/
This example compares the current values of the variables {a} and {b}. If {a} and {b} have the same value, Evaluate returns 0, meaning false. If {a} and {b} do not have the same value, Evaluate returns 1, meaning true. The command
Evaluate "{a}" !~ /$[0-9a-f]+/
returns 1 (for true) if the variable {a} does not contain a hexadecimal number.
The << operator performs a shift left function on a number. A shift left function shifts a value's bits n characters to the left. The bits that are shifted out through the high-order bit are lost. For example, if you enter
Evaluate 3 << 1
the bit pattern in the number 3 is shifted left by one place. In other words, the bit pattern
... 0000 0011 #the value 3
becomes
... 0000 0110 #the value 6
Shifting left one place actually has the effect of multiplying a value by 2.
The >> operator performs a shift right function on a number. A shift right function shifts a value's bits n characters to the right. The bits moved out of the low-order bit are lost, and the bits shifted in to the high-order bits on the left have a value of 0. For example, if you enter
Evaluate 3 >> 1
the bit pattern
... 0000 0011
becomes
... 0000 0001
which has a value of 1. The right shift is a logical right shift, because bits with a value of 0 are moved into the high-order bits.