cs.iterate()

Description:

Perform iterative loop on record sequences in a cursor and return the result of the last calculation of a given expression.

Syntax:

cs.iterate(x,a,c)

Note:

The function loops through record sequences in cursor cs to calculate expression x and returns the result of the last calculation of x. ~~ represents the previous value of x. Parameter a is the default initial value for each calculation, whose absence indicates a null initial value. Exit the loop once the result of expression c is true.

Parameter:

cs

A cursor

x

An expression

a

Initial value

c

An expression returns true/false

Return value:

Result of expression x

Example:

 

A

 

1

=[2,222,22,122,2222].cursor()

 

2

=A1.iterate(~*2)

4444

3

=[2,222,22,122,2222].cursor().iterate(~~*2,3)

96

4

=[2,222,22,122,2222].cursor().iterate(~~*2,5,~>500)

80

5

=demo.cursor("select * from SALES")

 

6

=A5.(AMOUNT).iterate(~~*2,5,~>20000)

40