Documentation

Expressions

TeSSH implements full expressions. Expressions can contain variables, and most common operators. Parenthesis can be used to override default operator precedence. When evaluating an operation, if all parameters of the operation are numeric, then a numeric operation is used, otherwise a string operation is used. The following operators are recognized (v1 and v2 represent variables, or other expressions). The list is in precedence order, with the highest precedence operators at the top.

  • !v1 return the logical NOT of value1
  • not v1 same as above
  • -v1 return the negative of value1
  • v1 * v2 multiply value1 by value2
  • v1 / v2 divide v1 by v2. Any fraction is discarded.
  • v1 \ v2 divide v1 by v2 and return the modulus
  • v1 + v2 add value1 to value2. If values are not numeric, the text values are concatenated.
  • v1 - v2 subtract value2 from value1
  • v1 = v2 true if value1 is the same as value2
  • v1 > v2 true if value1 is greater than value2
  • v1 < v2 true if value1 is less than value2
  • v1 >= v2 true if value1 is greater than or equal to value2
  • v1 <= v2 true if value1 is less than or equal to value2
  • v1 <> v2 true if value1 is not equal to value2
  • v1 != v2 true if value1 is not equal to value2
  • v1 =~ v2 true if the string v1 matches the pattern in v2
  • v1 LIKE v2 same as above (added in v2.0)
  • v1 && v2 returns the logical AND of value1 and value2
  • v1 AND v2 same as above
  • v1 || v2 returns the logical OR of value1 and value2
  • v1 OR v2 same as above
  • v1 XOR v2 returns the logical XOR of value1 and value2

If the pattern matching =~ or LIKE operator is used, any saved pattern parameters are available through the %pat function.

The constant true is defined with a value of 1, and the constant false is defined with a value of 0.

Keep in mind that the AND, OR, XOR, and NOT operators are logical operators and not bitwise operation. For bitwise operations, use the various bitwise functions in TeSSH. For example: (2 AND 4) is true using the logical operation, but %bitand(2,4) returns zero, which is false!

Add comment

Login or register to post comments