HARSFEN0602ElmoHARmonicaSoftwareManual

PRELIMINARYDRAFT

Perform an indexed iteration in a program.

Syntax:

for k=N1:N2:N3

end or

for k=N1:N2

end

where N1, N2, and N3 are numbers or simple expressions.

The syntax:

for k=N1:N2:N3

end

iterates k from N1 to N3 with a step of N2.

The syntax: for k=N1:N2

end

iterates k from N1 to N2 with a step of 1.

Notes:

1.If the iteration step is zero, the program is aborted with the error code

INFINITE_LOOP.

2.If N1, or N2, or N3 are variables, they are evaluated once before the iteration begins. If the variable changes within the "for" loop, the iteration process will not be affected.

3.Iteration variable k must be declared as a variable.

Example:

….

Start user program or function

float ra[20];

Float array declaration

int ia[20];

Integer array declaration

int k;

Variable declaration

 

for k=1:10

Start of iteration loop

ia[k]=100;

Update the first ten elements of the integer

 

array

ra[k]=55.55;

Update the first ten elements of the real array

 

end

End of iteration loop

….

 

36

5.5.3While iteration

Page 38
Image 38
Elmo HARmonica, HARSFEN0602 software manual While iteration, Infiniteloop