There are a lot of times we use a loop just to repeat a finite number of times
It would be usefull to have a new loop statement like this
sub procedure
repeat 8
' everything we want to do 8 times
end repeat
end sub
sometimes is clearer than the rest of loops
The repeat statement
Then it won't be Basic anymoresub procedure
repeat 8
' everything we want to do 8 times
end repeat
end sub
Another proud user of LV 24-33A Development System and mikroPascal PRO for dsPIC :)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)
PortA not working? Add CMCON := 7; PortD not working? Add ADCON1 := 6;
To paste code on the forum, please use the [b] Code [/b] button !! ;)
I don't intend supressing the for loop
I think repeat allows to avoid using a variable .
Probably in assembler it allows a more efficient code.
You don't have to worry about limits in the for loop
Of course it's possible to live without it
Probably in assembler it allows a more efficient code.
You don't have to worry about limits in the for loop
Of course it's possible to live without it
For-Next is a very flexible type of loop that also does simple Repeat.
Also:
b is the start variable value and c is the stop variable value (no redundancy here). Using variables instead of constants allows for a flexible Repeat sequence and saves on code size.
Code: Select all
FOR a = b TO c
'Some more code
NEXT a
Code: Select all
FOR a = b TO c STEP d
'Some code
NEXT a
[color=darkred][b]xor[/b][/color]
[url=http://circuit-ed.com]CircuitED -[/url]
[url=http://circuit-ed.com]CircuitED -[/url]