if: Difference between revisions
Jump to navigation
Jump to search
(New page: ==Function if== If testCondition evaluates to 0 then the result of falseExpr is returned, otherwise the result of trueExpr is returned. Note: '''both''' trueExpr and falseExpr are evaluate...) |
|||
Line 11: | Line 11: | ||
<source lang="mtmacro" line> | <source lang="mtmacro" line> | ||
[r: if(a>b, "A is larger than B", "A is not larger than B")] | [r: if(a>b, "A is larger than B", "A is not larger than B")] | ||
</source> | [someProperty = if(variable==1,20,"")] | ||
</source>Sets someProperty to 20 if variable is equal to 1, or makes it blank (but not empty) otherwise. |
Revision as of 22:36, 13 January 2009
Function if
If testCondition evaluates to 0 then the result of falseExpr is returned, otherwise the result of trueExpr is returned. Note: both trueExpr and falseExpr are evaluated no matter what the result of testCondition is. You may want to consider using [if():] instead.
Usage
[h: result = if(testCondition, trueExpr, falseCondition)]
Examples
[r: if(a>b, "A is larger than B", "A is not larger than B")]
[someProperty = if(variable==1,20,"")]
Sets someProperty to 20 if variable is equal to 1, or makes it blank (but not empty) otherwise.