User`s manual

mikroBASIC
- Basic Compiler for Microchip PIC microcontrollers
For statement requires you to specify the number of iterations you want the loop
to go through. Syntax of for statement is:
for counter = initialValue to finalValue [step step_value]
statement_1
statement_2
...
statement_N
next counter
where counter is variable; initialValue and finalValue are expressions compatible
with counter; statement_X is any statement that does not change the value of
counter; step_value is value that is added to the counter in each iteration.
Step_value is optional, and defaults to 1 if not stated otherwise. Be careful when
using large values for step_value, as overflow may occur.
Every statement between
for and next will be executed once for each iteration.
Be careful not to create endless loop by mistake. The following statement:
for counter = initialValue to finalValue
statement
next counter
will result in an an endless loop if finalValue is greater than, or equal to maximum
value of counter data type. For example, this will be an endless loop, if counter is
of byte type:
for counter = 0 to 255
nop
next counter
' or
for counter = 0 to 500
nop
next counter
MikroElektronika:
Development
tools
-
Books
-
Compilers
mikroBASIC
making it simple...
93
page
For Statement
Endless
Loop