with do_all, exact tells the engine how many times you want it to do everything within the do_all node. counter just gives you the index of any particular iteration. helps to tell specific iterations apart or compare values between them.
so:
Code: Select all
<set_value name="$somelist" exact="[0.1, 3000, 20]"/>
<do_all exact="$somelist.count" counter="$counter">
<do_if value="$somelist.{$counter} gt @$highestvalue">
<set_value name="$highestvalue" exact="$somelist.{$counter}"/>
<set_value name="$highestvalueindex" exact="$counter"/>
</do_if>
</do_all>
<do_if value="$highestvalue?">
<debug_text text="'highest value is: %s at index: %s'.[$highestvalue, $highestvalueindex]"/>
</do_if>
should print "highest value is: 3000 at index: 2"
it'll first record 0.1 as $highestvalue with index 1,
then overwrite that value and record 3000 as $highestvalue with index 2,
then ignore the third value since it'll fail the condition within the loop.
do note that do_all doesn't necessarily have to be used in loops. it can simply be an instruction to the engine to do everything within the node. limited usage since that's implicitly true in most cases (all but one, i think).
also note that you could also use the tidier do_for_each in most cases where you need to iterate over a number of entries in a list or table.