Repetetive execution of statements in a custom function, controlled by a counter.
FOR(counter_name:Text, start:Number, end:Number {, step:Number})
The named counter is initialised to start.
Statements in the loop are executed if the counter is less than, or equal to, end.
The NEXT
statement signals the end of an iteration.
At the end of each iteration 1 (one) is added to the counter,
unless the optional step parameter is specified,
in which case that value is added.
When the counter passes the end value, execution continues after the NEXT
statement.
If step is negative, the loop will be iterated while the counter is greater than, or equal to, end.
The following example scans an array of numbers and builds a set of square roots of the number in column D, checking for negative roots along the way:
FOR("i", 1, rows(@list)) IF(index(@list, 1, i) < 0) SET_VALUE(INDEX(D1:D100, 1, i), 0) ELSE SET_VALUE(INDEX(D1:D100, 1, i), SQR(INDEX(@list, 1, i))) ENDIF NEXT