language expression is similar to VBScript
language expression, but has more operators and therefore is more general and versatile (see Operators list of the VBScript
(4 * x + 1) / 3
- The expression for logical operations like "and", "or" ... are different, e.g.
expression (e.g. b ? 1 : 2
) cannot be written in VBScript
expression is used in the PROMOTIC system:
- in the PmExpr
|v1 + v2 ||Addition of numbers or strings addition|
|v1 - v2 ||Subtraction of numbers|
|v1 * v2 ||Multiplication of numbers|
|v1 / v2 ||Division of numbers|
|v1 % v2 ||Modulo (remainder after division v1/v2)|
|v1 ? v2 : v3 ||If the value v1 is true, then the value v2 is returned, otherwise the value v3 is returned|
|v1++ ||Increment of number = increments a variable by one (v1=v1+1)|
|v1-- ||Decrement of number = decrements a variable by one (v1=v1-1)|
val = 1 + 2; //Returns 3
val = true + 1; //Returns 2
val = false + false; //Returns 0
val = 6 + "Boiler"; //Returns "6Boiler"
val = "Boiler" + false; //Returns "Boilerfalse"
val = "Boiler" + "Valve"; //Returns "BoilerValve"
val = 12 % 5; //Returns 2
val = -1 % 2; //Returns -1
val = 1 % -2; //Returns 1
val = -4 % 2; //Returns -0
val = 5.5 % 2; //Returns 1.5
|v1 == v2 ||Returns true if v1 and v2 values are the same|
|v1 != v2 ||Returns true if v1 and v2 values are not the same|
|v1 >= v2 ||Returns true if v1 is greater or equal v2|
|v1 > v2 ||Returns true if v1 is greater than v2|
|v1 <= v2 ||Returns true if v1 is less or equal v2|
|v1 < v2 ||Returns true if v1 is less than v2|
- Two values of the String
type (text) are compared based on standard lexicographical ordering, using Unicode
- When comparing a number and a string, the string is converted to a number value.
- If one of the operands is of the Boolean type, then this operand is converted to 1 if it is true and 0 if it is false.
val = 1 == 1; //Returns true
val = 1 == "1"; //Returns true
val = "1" == 1; //Returns true
val = 0 == false; //Returns true
val = 1 != 2; //Returns true
val = 1 != "1"; //Returns false
val = 1 != true; //Returns false
val = 0 != false; //Returns false
| v1 && v2 ||Logical AND (returns true if v1 and v2 is true)|
|v1 || v2 ||Logical OR (returns true if v1 or v2 is true)|
|!v1 ||Logical NOT (returns true if v1 is false)|
|v1 & v2 ||Bitwise AND (each bit of the returned value is a result of AND operation of corresponding bits in v1 and v2)|
|v1 | v2 ||Bitwise OR (each bit of the returned value is a result of OR operation of corresponding bits in v1 and v2)|
|v1 ^ v2 ||Bitwise XOR (each bit of the returned value is a result of XOR operation of corresponding bits in v1 and v2|
|~v1 ||Bitwise NOT (each bit of returned value is the result of NOT operation of corresponding bit in v1). Not implemented in the PROMOTIC system so far.|
|v1 << v2 ||Bitwise leftshift (the bit values in v1 are shifted by v2 number of bits left). For example v1<<2 returns double the v1 value.|
|v1 >> v2 ||Bitwise rightshift (the bit values in v1 are shifted by v2 number of bits right). For example v1>>2 returns the whole number division of v1/2.|
language require whole number values (4-byte integer).
If the value is not a integer, then the operator has to transform it to integer first.
If the value cannot be transformed, then the operator returns the NaN value.