An xreporter Expression based algorithm that repeats the formula on a
set of fields.
The specified formula will be applied iterating on the specified widgets. The final result will be the result of the
last iteration. From inside the formula you can access this two extra variables :
formulaResult
The result of the previous iteration, or the result of the initial result if this is the first iteration.
formulaCurrent
The value of the current trigger widget.
The initial result is evaluated before starting the iteration, and its value is used as a formulaResult for the
first iteration.
It's possible to define nearly every cyclic arithmetic operation with this algorithm, for example :
More over, thru the use of advanced xreporter syntax it's possible to quickly implement also complex
algorithms:
Count all items with a price higher than 100 : eval="formulaResult + If(price > 100, 1, 0)"
(read : the result is the previous result plus one if price is over 100, 0 if price is less than 100)
Obtain a sum of all movements, wether they are positive or negative amount movements :
eval="formulaResult + Abs(amount)"
Count how many slots are empty in the 10 items box you are using for packaging :
eval="formulaResult + Reminder(items, 10)"
Note: please take care that xreporter expressions are not that accurate when it comes to decimals. The default
divide operator rounds the result, see http://issues.cocoondev.org/browse/XRP-115. Also consider that the
available set of functions can be expanded implementing and using new ones. Please see
http://outerthought.net/wqm/xreporter/en/expressions.html for an overview of xreportes expressions and
IsNullFunction or
StringFunction
for examples of custom xreporter functions.