Difference between revisions of "Complex formulas"

From TempusServa wiki
Jump to navigation Jump to search
old>Admin
m (15 revisions imported)
(No difference)

Revision as of 11:51, 10 December 2021

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

 ( 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] )