Datasheet
Programming PIC Microcontrollers in BASIC - mikroElektronika
Description For statement requires you to specify the number of iterations you want the loop to go 
through.
Counter is variable; initialValue and finalValue are expressions compatible with 
counter; statement 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 per iteration.
Example Here is a simple example of a FOR loop used for emitting hex code on PORTB for 7-
segment display with common cathode. Nine digits should be printed with one second 
delay.
for i = 1 to 9
 portb = i
 delay_ms(1000)
next i
4.2.2 DO..LOOP Statement – Loop until condition is fulfilled
Syntax
do
 statement_1
 ...
 statement_N
loop until expression
Description Expression returns a True or False value. The do..loop statement executes 
statement_1; ...; statement_N continually, checking the expression after each 
iteration. Eventually, when expression returns True, the do..loop statement 
terminates.
The sequence is executed at least once because the check takes place in the end.
http://www.mikroelektronika.co.yu/english/product/books/picbasicbook/04.htm (7 sur 9)05/11/2004 02:15:36










