Rice Lake iRite IDE User Manual

Page 30

Advertising
background image

26

920i

Programming Reference

for <name> := <expression> to <expression> step <expression>

loop

<statement list>

end loop;

expr

optional-step-clause

FOR

WHILE

expr

name

TO

expr

:=

Figure 3-16. Optional Loop Iteration Clause Syntax

The optional step clause can be omitted if you want <name> to increment by 1 after each run of the statement
list. If you want to increment <name> by 2 or 3, or decrement it by 1 or 2, then you have to use the step clause.
The step expression (–1 in the second example below) must be a constant.

for iCount := 97 to 122

loop

strAlpha := strAlpha + chr$(iCount);

end loop;

for iCount := 10 to 0 step -1

loop

if iCount = 0 then

strMissionControl := "Blast off!";

else

strMissionControl := IntegerToString(iCount, 2);

end if;

end loop;

STEP

expr

Figure 3-17. Optional Step Clause Syntax

Note

Use caution when designing loops to ensure that you don’t create an infinite loop. If your program
encounters an infinite loop, only the loop will run; subsequent queued events will not be run.

Advertising
This manual is related to the following products: