Configuration parameters

The FOREACH function implements a for loop on a list or map.

For each iteration i on a list, the i-th element on the list is put on top of the stack, and the exec macro is then called.

For each iteration i on a map, the exec macro is called with the i-th value on top of the stack, and the i-th key just below on the stack. You can start your macro with 'value' STORE 'key' STORE.

Since release 2.1, FOREACH has the ability to iterate over Geo Time Series™ and GTS Encoders. When iterating over a GTS or Encoder, the macro is fed with a list of the form [ tick lat lon elev value ] where lat, lon and elev may be NaN if unset. In the case of an Encoder, value can be a byte array or a BigDecimal on top of LONG, DOUBLE, STRING or BOOLEAN.

Since release 2.4.0, you can force FOREACH to push an index (iteration count, start at 0) on the top of the stack before calling the macro.

FOREACH is available since version 1.0.0.

See also



// define macro <% 2 ** %> 'SQUARE' STORE // FOREACH loop { 1 -2 3 -4 5 -6 } $SQUARE FOREACH
{ 'audi' 35 'dacia' 342 'renault' 200 'porsche' 14 } 'brandcountMAP' STORE 0 'total' STORE //total count 'Sum of following car makers: ' $brandcountMAP <% 'value' STORE 'key' STORE $total $value + 'total' STORE //add value to total count. $key + ' ' + //concatenate brands on the stack %> FOREACH '= ' + $total TOSTRING + //concatenate the total to the string on the stack