SAT Markup Language (SAT/ML) Macros |
|
Home | SATGUI | SATSHELL | SATFORM | SATFILTER | SATREPORT | SATMYSQL | License | Download | Examples | Contact |
Introduction |
SAT/ML macros provide a facility to perform conditional/case 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}}
Case Macros |
Case macros have the following format:
{testvalue::testlist;resultlist}
Testlist and resultlist must be comma delimited lists:
value1,value2,value2,...
The values may contain spaces, but not reserved characters (comma, colon, semi-colon, ampersand).
Testvalue is compared with each item in testlist. Where a match is found the macro is replaced by the corresponding item in resultlist. For example: If testvalue matches the third item in testlist, the macro is replaced with by the third item in resultlist. If a default result is required where no match is found, an extra item should be added to resultlist. This will be used as the default result. If there is no match (and no default is set) -or- there is no corresponding item in resultlist, the macro will be replaced by null.
Examples:
Value of ${period} | Macro | Replaced with |
W | {${period}::D,W,M;Daily,Weekly,Monthly} | Weekly |
Y | {${period}::D,W,M;Daily,Weekly,Monthly} | "null" |
Y | {${period}::D,W,M;Daily,Weekly,Monthly,Yearly} | Yearly |
FRED | {${period}::D,W,M;Daily,Weekly,Monthly,Yearly} | Yearly |
String Macros |
String macros have the following format:
{string:@:start,length}
The macro is replaced by the section of string from start for length characters. The string may contain spaces.
If length is not specified all characters from start to the end of string are returned.
If start is set to "-" the last length characters are returned. If start is set to "+" the first length characters are returned.
Examples:
Macro | Replaced with |
{mystring:@:1,2} | my |
{mystring:@:3} | string |
{mystring:@:+,2} | my |
{mystring:@:-,6} | string |
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}} |