...how to do calculations and formulas in TW. At the moment I would like to do the following:
=INT(({{!!myfield}}-10)/2)
Calculations are done using the "filter" syntax. There are several ways to do this.
* direct rendering using "filtered transclusion"
{{{ [{!!myfield}subtract[10]divide[2]trunc[]] }}}
* using the $set widget with "filter" parameter
<$set name="result" filter="[{!!myfield}subtract[10]divide[2]trunc[]]">
* using the $vars widget with filtered transclusion as a parameter
<$vars result={{{ [{!!myfield}subtract[10]divide[2]trunc[]] }}}>
Notes:
* within the filter syntax, field references use *single* curly braces.
* there isn't any filter syntax for using parentheses in calculations, so the order of operations is very important
* sometimes this means using several filters to calculate intermediate results and then combining them.
For example, to calculate something like this:
INT(({!!myfield} / 2) - ({!!myfield} - 5))
You could write:
<$vars part1={{{ [{!!myfield}divide[2]] }}} part2={{{ [{!!myfield}subtract[5]] }}}>
<$vars result={{{ [<part1>subtract<part2>trunc[]] }}}
enjoy,
-e