for x

Read(987) Label: execute a loop,

Description:

Start a loop.

Syntax:

for  x

Note:

The statement starts a loop executing the code block.

Parameter:

x

A sequence, an integer, or a logic expression. Loop through the code block against x or to(x), or if x is true. If x is empty, then the loop will be endless

Example:

x is an integer:

 

A

B

 

1

 

 

Save the cumulative total 55 in A1.

2

for 10

 

 

3

 

>A1=A1+A2

Add up integers from 1 to 10.

 

x is empty:

 

A

B

C

 

1

=0

 

 

5050.

2

for

 

 

Loop will be endless if x is empty. When the loop count reaches 100, then break the loop.

3

 

>A1=A1+#A2

 

 

4

 

if #A2==100

break

 

x is a Boolean expression:

 

A

B

 

1

=15

 

 

2

for A1>10

 

If A1 >10, then start a loop through the code block; otherwise, quit the loop.

3

 

>B1=B1+#A2

4

 

>A1=A1-1

 

 

x is a sequence:

 

A

B

 

1

=demo.query("select * from EMPLOYEE")

0

Get the oldest age among all Texas employees in B1 after the loop is over.

2

=A1.select(STATE=="Texas")

 

 

3

for A2

=age(A3.BIRTHDAY)

A3 performs loop over each Texas employee while computing their age.

4

 

>B1=max(B1,B3)

The oldest age is stored in B1.