Expression Evaluator
Release 1.0 - ...
Smartsite includes a powerful mathematical expression evaluator .
Smartsite SXML | Copy Code |
---|---|
(1+2)*(3+4*5/6) => 18 string.toupper("your") + " name?" => YOUR name? |
To test expressions within the SXML environment, you can use the viper sys.eval:
Smartsite SXML | Copy Code |
---|---|
{sys.eval( (1+2)*(3+4*5/6) )} => 18 {sys.eval( string.toupper("your") + " name?" )} => YOUR name? |
The expression evaluator supports an unlimited number of expressions and unlimited nesting using brackets.
The following types are supported natively:
- boolean
- integer
- string
- float
- datetime
- vipermethod
The following operators are supported:
- Unary: +, -, !, ~, $
- Arithmetic: *, /, %, +, -
- Shift: <<, >>
- Relational: <, >, <=, >=
- Equality: ==, !=
- Logical: &, ^, |
- Conditional: &&, ||
- Statement separator: ;
Operators containing <, > or & cannot be used directly within element attributes.
To use these operators within attributes, use the standard XML escaping <, > and & or use the aliases listed below:
Operator aliases:
- AND for &&
- OR for ||
- EQ for ==
- NEQ for !=
- LT for <
- GT or >
- LTE <=
- GTE for >=
Note that to avoid confusion with other types, these operator aliases must be uppercase and surrounded by exactly one space character.
Examples:
Smartsite SXML | Copy Code |
---|---|
{sys.eval(7 AND 3)} => true (AND treated as an operator) {sys.eval(7AND3)} => 7AND3 (AND treated as part of a string) |