Onetastic Macro Documentation >
>
Operators Operators
Macro expressions can contain several different operators. They can be used for
assignments, comparisons, arithmetic or logical operations and string concatenations.
Following is a list of all the operators. Operators can be operating on one (unary), two
(binary) or three (ternary) sub expressions:
Arithmetic Operators |
Operator | Name | Type |
+ | Addition | binary |
– | Subtraction | binary |
* | Multiplication | binary |
/ | Division | binary |
% | Modulo | binary |
– | Unary Minus | unary |
+ | Unary Plus | unary |
|
Increment/Decrement Operators |
Operator | Name | Type |
++$v | Pre-Increment | unary |
––$v | Pre-Decrement | unary |
$v++ | Post-Increment | unary |
$v–– | Post-Decrement | unary |
|
Assignment Operators |
Operator | Name | Type |
= | Assignment | binary |
+= | Addition Assignment | binary |
–= | Subtraction Assignment | binary |
*= | Multiplication Assignment | binary |
/= | Division Assignment | binary |
%= | Modulo Assignment | binary |
&&= | Logical And Assignment | binary |
||= | Logical Or Assignment | binary |
&= | Concatenation Assignment | binary |
|
Comparison Operators |
Operator | Name | Type |
== | Equals | binary |
!= | Not Equals | binary |
< | Less Than | binary |
<= | Less Than or Equals | binary |
> | Greater Than | binary |
>= | Greater Than or Equals | binary |
|
Logical Operators |
Operator | Name | Type |
&& | Logical And | binary |
|| | Logical Or | binary |
! | Logical Not | unary |
|
String Concatenation Operator |
Operator | Name | Type |
& | Concatenation | binary |
|
Ternary Operator |
Operator | Name | Type |
?: | Ternary Operator | ternary |
Operator Precedence
In macro expressions, following operator precedence rules apply. The order of operations
can be changed by providing parantheses. The Expression Editor automatically fully
parenthesizes any expression so that what operator precedence rules were used is obvious.
If you type 5 == 2 + 3 * 4 to Expression Editor it will automatically parse and convert it to
5 == (2 + (3 * 4)).
Precedence | Category | Operators |
1 | Increment/Decrement | ++ | –– | | | | | | | |
2 | Unary | ! | – | + | | | | | | |
3 | Product | * | / | % | | | | | | |
4 | Sum & Concatenation | + | – | & | | | | | | |
5 | Comparison | == | != | < | <= | > | >= | | | |
6 | Logical And | && | | | | | | | | |
7 | Logical Or | || | | | | | | | | |
8 | Ternary | ?: | | | | | | | | |
9 | Assignment | = | += | –= | *= | /= | %= | &&= | ||= | &= |
Note: Assignments are evaluated right to left
|