Difference between revisions of "Complex formulas"
Jump to navigation
Jump to search
old>Admin |
|||
(10 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
Calculated formulas syntax follows is compliant with JavaScript syntax. | |||
==== Common operators ==== | ==== Common operators ==== | ||
Line 6: | Line 7: | ||
* Multiply: * | * Multiply: * | ||
* Modulus: % | * Modulus: % | ||
* Precedence: ( ... ) | |||
==== Mathematical functions ==== | ==== Mathematical functions ==== | ||
* Minimum | * Absolute: abs | ||
* Maximum | * 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 ==== | ==== 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 26: | Line 39: | ||
*** Lesser: < (<=) | *** Lesser: < (<=) | ||
** Second value or expression | ** Second value or expression | ||
* | * Result | ||
** | ** TRUE value or expression | ||
** | ** FALSE value or expression | ||
===== Examples ===== | ===== Examples ===== | ||
Script code | Script code / specification | ||
var result; | |||
if ( [NUMBER1] > [NUMBER2] ) { | |||
result = [NUMBER1] * 11; | |||
} | |||
else { | |||
result = [NUMBER3]; | |||
} | |||
return result; | |||
Expression | Expression to use in formula | ||
( [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] )