Difference between revisions of "Complex formulas"
Jump to navigation
Jump to search
old>Admin |
|||
(4 intermediate revisions by 2 users not shown) | |||
Line 23: | Line 23: | ||
==== Support for statements ==== | ==== Support for statements ==== | ||
This feature is enabled starting from version 2366. | |||
===== IF statement ===== | ===== IF statement ===== | ||
Syntax used matches JavaScript inline IF statments | Syntax used matches JavaScript inline IF statments. | ||
To make the statement work make sure to add a space: before <code>)</code>, after <code>(</code>, before and after <code>?</code> and <code>:</code>.<syntaxhighlight lang="js"> | |||
( Value1 Operator Value2 ? ValueIfTrue : ValueIfFalse ) | |||
</syntaxhighlight> | |||
* Test | * Test | ||
** First value or expression | ** First value or expression | ||
Line 37: | Line 39: | ||
*** Lesser: < (<=) | *** Lesser: < (<=) | ||
** Second value or expression | ** Second value or expression | ||
* | * Result | ||
** | ** TRUE value or expression | ||
** | ** FALSE value or expression | ||
===== Examples ===== | ===== Examples ===== | ||
Line 52: | Line 54: | ||
} | } | ||
return result; | return result; | ||
Expression to use in formula | Expression to use in formula | ||
( [NUMBER1] > [NUMBER2] ? [NUMBER1] * 11 : [NUMBER3] ) | ( [NUMBER1] > [NUMBER2] ? [NUMBER1] * 11 : [NUMBER3] ) |
Latest revision as of 09:43, 19 August 2022
Calculated formulas syntax follows is compliant with JavaScript syntax.
Common operators
- Add: +
- Subtract: -
- Division: /
- Multiply: *
- Modulus: %
- Precedence: ( ... )
Mathematical functions
- Absolute: abs
- Minimum: max
- Maximum: min
- Power: pow
- Square root: sqrt
- Logarithms: log log10 exp
- Rounding: ceil floor round
Mathematical constants
- Pi: pi
- E: e
Support for statements
This feature is enabled starting from version 2366.
IF statement
Syntax used matches JavaScript inline IF statments.
To make the statement work make sure to add a space: before )
, after (
, before and after ?
and :
.
( Value1 Operator Value2 ? ValueIfTrue : ValueIfFalse )
- Test
- First value or expression
- Operator
- Equal: =
- Unequal: !=
- Greater: > (>=)
- Lesser: < (<=)
- Second value or expression
- Result
- TRUE value or expression
- FALSE value or expression
Examples
Script code / specification
var result; if ( [NUMBER1] > [NUMBER2] ) { result = [NUMBER1] * 11; } else { result = [NUMBER3]; } return result;
Expression to use in formula
( [NUMBER1] > [NUMBER2] ? [NUMBER1] * 11 : [NUMBER3] )