syntax:operators
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revisionLast revisionBoth sides next revision | ||
syntax:operators [2014/09/08 21:39] – created dmitry | syntax:operators [2021/01/13 18:36] – dmitry | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Operators ====== | ====== Operators ====== | ||
- | Here is list of operators that can be used in expressions in EasyMorph. | + | Here is a list of operators that can be used in expressions in EasyMorph. |
+ | |||
+ | === Basic operators === | ||
^ Operator | ^ Operator | ||
Line 12: | Line 14: | ||
| >= | Greater than or equal | Boolean | | >= | Greater than or equal | Boolean | ||
| < | Less than | Boolean | | < | Less than | Boolean | ||
- | | <= | Less than or equal | Boolean | + | | |
| = | Equal | Boolean | | = | Equal | Boolean | ||
| != | Not equal | Boolean | | != | Not equal | Boolean | ||
+ | | <> | ||
| and | Logical AND | Boolean | | and | Logical AND | Boolean | ||
| or | Logical OR | Boolean | | or | Logical OR | Boolean | ||
Line 21: | Line 24: | ||
Examples of operators in expressions: | Examples of operators in expressions: | ||
1 + 2 | 1 + 2 | ||
+ | | ||
(10 + 5 ) * 3 | (10 + 5 ) * 3 | ||
+ | | ||
' | ' | ||
+ | | ||
[Amount] > 1000 | [Amount] > 1000 | ||
+ | | ||
([Amount] > 1000 and [Quantity] > 1) or [Quantity]> | ([Amount] > 1000 and [Quantity] > 1) or [Quantity]> | ||
+ | | ||
+ | === The IF..THEN..ELSE operator === | ||
+ | This operator can be used to perform conditional calculations. It has the following syntax: | ||
+ | |||
+ | IF // | ||
+ | |||
+ | A shorter form where the ELSE expression is omitted and always returns an empty value is also possible: | ||
+ | |||
+ | IF // | ||
+ | |||
+ | Note that unlike the [[syntax: | ||
+ | |||
+ | Examples: | ||
+ | |||
+ | IF [Amount] > 1000 THEN 'Large order' ELSE 'Small order' | ||
+ | |||
+ | IF [Year] = year(today()) THEN [Amount] ELSE 0 | ||
+ | |||
+ | IF [Qty] = 0 THEN 0 ELSE [Amount] / [Qty] // Doesn' | ||
+ | | ||
+ | === The LET operator === | ||
+ | The LET operator allows simplifying expressions by declaring repetitive parts as local constants which can later be used instead of the repetitive parts. The operator has the following syntax: | ||
+ | |||
+ | LET // | ||
+ | |||
+ | Once a local constant is declared, it can be used in the expression(s) that follow the declaration. Example: | ||
+ | |||
+ | LET d = day(today()) | ||
+ | IF d=1 THEN 'First day' ELSE 'Day: ' & d | ||
+ | |||
+ | === The ASSUME operator === | ||
+ | The operator allows creating guarding conditions that must evaluate to TRUE before the expression is evaluated. ASSUME can be used to ensure data quality and integrity right in expressions. Examples: | ||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | In the expression above, the final statement will only be calculated if [Tax] is not negative. Otherwise, project execution will be aborted with a generic error. | ||
+ | |||
+ | It is also possible to specify a custom error message as follows: | ||
+ | |||
+ | | ||
+ | |||
+ | The OTHERWISE keyword is optional. It can be safely omitted: | ||
+ | |||
+ | | ||
+ | |||
+ | All the operators can be used together. For instance: | ||
+ | |||
+ | | ||
+ | LET tax = [Tax base] * {Tax Rate} - [Tax credit] | ||
+ | | ||
+ | | ||
+ | |||
+ |
syntax/operators.txt · Last modified: 2021/01/13 18:43 by dmitry