SAT Markup Language (SAT/ML) Macros |
Introduction |
SAT/ML macros provide a facility to perform conditional processing and calculations.
Conditional Macros |
Conditional macros have the following format:
{operand1:operator:operand2;true value;false value}
Operand1 is compared with operand2 to check if the condition defined by the operator is true or false. If the condition is true the macro is replaced by the true value, otherwise the macro is replaced by the false value. Either the true value or false value can be null.
In general spaces should not be used in the conditional part of the macro, as the spaces are treated literally.
Examples:
Condition | Operand2 |
{${name}:=:PAUL;... | "PAUL" |
{${name}:=: PAUL;... | " PAUL" |
The operands may be numeric or string type. If both operands are numeric then the comparison will be numeric (where applicable), otherwise a string comparison is performed.
Operators:
Operator | Action |
= | Equal |
!= | Not Equal |
> | Greater Than |
>= | Greater Than/Equal |
< | Less Than |
<= | Less Than/Equal |
~ | Regular Expression Match |
!~ | Not Regular Expression Match |
Examples:
Value of ${amount} | Macro | Replaced with |
112.02 | {${amount}:>:0;Credit;Debit} | Credit |
-56.47 | {${amount}:>:0;Credit;Debit} | Debit |
Value of ${agree} | Macro | Replaced with |
Y | {${agree}:=:Y;agreed;turned down} | agreed |
N | {${agree}:=:Y;agreed;turned down} | turned down |
Value of ${type} | Macro | Replaced with |
A | {ABC:~:${type};<insert paragraph1>;<!>} | <insert paragraph1> |
E | {ABC:~:${type};<insert paragraph1>;<!>} | <!> |
Conditional macros can be nested. The operands and the values can themselves be macros. Any part of a macro, including the operator, can be a variable data value.
Examples:
Macro |
{${amount}:>:{${type}:=:A;150;500};Limit Exceeded;;} |
{${value1}:${test}:${value2};True;False} |
It is possible to perform AND/OR comparisons by nesting conditional macros.
In the examples operand1:operator:operand2 is, for the purpose of clarity, replaced by condition.
The result of the following is true if both condition1 AND condition2 are true.
{condition1;{condition2;true;false};false}
The result of the following is true if either condition1 OR condition2 is true.
{condition1;true;{condition2;true;false}}
Calculation Macros |
Calculation macros have the following format:
{operand1:operator:operand2}
The macro is replaced by the result of the calculation.
Both operands must be numeric. If either of the operands has a decimal part, the result will have two decimal places.
Operators:
Operator | Action |
+ | Add |
- | Subtract |
* | Multiply |
/ | Divide |
Examples:
Assume amount1 is 2.3, amount2 is 12 and amount3 is 4.
Macro | Replaced with |
{${amount1}:+:${amount2}} | 14.30 |
{${amount2}:-:${amount3}} | 8 |
{${amount2}:*:2} | 24 |
{24:/:${amount3}} | 6 |
More complex calculations can be performed by nesting calculation macros. The braces in the macros are equivalent to brackets.
Examples:
Calculation | Macro |
10/(3+2) | {10:/:{3:+:2}} |
(amount/100) * percent | {{${amount}:/:100}:*:${percent}} |