search:

General



Rooms & Areas



Presence



Systems



Wiki Help



pmwiki.org



edit menu
Edit Page Upload Security

Expressions

Expressions calculate equations and formulas and return a single value as a result. The expression must contain numbers or strings surrounded by quotation marks. Floating-point precision data is accepted and calculated correctly by the expression-handling engine, but EaxiaSEL can only store whole-number integer data (so rounding down will always occur upon assignment). Expressions will result in $result being set to 1 if there is an error with your syntax. The following conditions can result in error:

  • There are a mismatched number of parenthesis in the expression.
  • There are symbols in the expression that are not recognized.
  • An expression does not make logical sense. Example: (14 / 7) * (+ 1)
  • An attempt to divide a number by zero is made. Since modulo relies on division, modulo expressions that divide by zero are also errors.
  • Operations on two unlike data types are made that do not make sense. For example: (5 + 2) And "Hello"
  • There are mismatched quotation marks.
Allowed expression operations on numeric values:
ExpressionOperation Type
a + breturns the result of adding 'b' to 'a'
a - breturns the result of subtracting 'b' from 'a'
a * breturns the result of multiplying 'b' with 'a'
a / breturns the result of dividing 'b' into 'a'
a % breturns the modulo of 'a' divided by 'b'
a == breturns true if 'a' is equal to 'b'
a != breturns true if 'a' is not equal to 'b'
a > breturns true if 'a' is greater than 'b'
a >= breturns true if 'a' is greater than or equal to 'b'
a < breturns true if 'a' is less than 'b'
a <= breturns true if 'a' is less than or equal to 'b'
a && breturns true if both evaluations are true (logical AND)
a || breturns true if either evaluations are true (logical OR)
a ! breturns true if the 'a' evaluation is true and the 'b' evaluation is false (logical NOT)
a Xor breturns true if either evaluations are true but not both evaluations (logical XOR)
a $$ breturns true if 'a' is an abbreviation of 'b', not case-sensitive (note: "", an empty string, is an abbreviation for everything)
a ## breturns true if 'b' is a substring of 'a'
a #@ breturns true if 'b' is a substring of 'a', not case-sensitive
a =@ breturns true if 'a' is equal to 'b', not case-sensitive
a !@ breturns true if 'a' is not equal to 'b', not case-sensitive
Allowed expression operations on mixed values (text and numeric):
ExpressionOperation Type
a == breturns true if 'a' is equal to 'b'
a != breturns true if 'a' is not equal to 'b'
a > breturns true if 'a' is greater than 'b'
a >= breturns true if 'a' is greater than or equal to 'b'
a < breturns true if 'a' is less than 'b'
a <= breturns true if 'a' is less than or equal to 'b'
a && breturns true if both evaluations are true (logical AND)
a || breturns true if either evaluations are true (logical OR)
a ! breturns true if the 'a' evaluation is true and the 'b' evaluation is false (logical NOT)
a Xor breturns true if either evaluations are true but not both evaluations (logical XOR)
a $$ breturns true if 'a' is an abbreviation of 'b', not case-sensitive (note: "", an empty string, is an abbreviation for everything)
a ## breturns true if 'b' is a substring of 'a'
a #@ breturns true if 'b' is a substring of 'a', not case-sensitive
a =@ breturns true if 'a' is equal to 'b', not case-sensitive
a !@ breturns true if 'a' is not equal to 'b', not case-sensitive
Substitute operations:
OperationValid substitute operation
And&&
Or||
Not!
*x
<>=

Note that empty parenthesis, excessive parenthesis, and parenthesis that contain values but no expressions are considered valid expressions. For example, (((4))) + () / (1 + 1) will evaluate to 2 because () is considered 0.

Example expressions:
ExpressionEvaluation
2 * (6 - 4)4
(((-3 * (1 + -2)) + 6) / 3) * -(2 + 3)-15
("asdf" == "asdf") Not (1 > 1)1
("5" = 5) And ("Bob" != "Fred") And (2 > 3)0

Boolean (true/false) results are 1 for TRUE and 0 for FALSE.

Recent Changes - Page History - Printable View
Page last modified on January 13, 2006, at 06:26 PM EST
PmWiki 2.20-beta16 - www.PmWiki.org