Beware! a Continue statement in the loop will miss changing the value of a, so this would need to be duplicated...
Code: Select all
b = 2 ; Step value
While a <= 10
Debug a
;some code
if somecondition
a + b : Continue
EndIf
;more code
a + b
Wend
But if b might be either positive or negative...
A Macro might help keep things tidy, and using a Repeat/Forever instead of a While/Wend
Code: Select all
a = ?? ; start value
b = ?? ; Step value
c = ?? ; Test value for end loop
Macro StepAndTest()
a + b
If ((b > 0) and (a >= c)) or ((b < 0) and (a <= c))
Break
EndIf
EndMacro
Repeat
Debug a
;some code
If somecondition
StepAndTest() : Continue
EndIf
;more code
StepAndTest()
ForEver
UndefineMacro StepAndTest
There are two bonuses when compared to a conventional For/Next/Step loop, apart from having a variable step. One is that all the loop variables don't have to be integers (that has its dangers, too, of course : 1.1 + 2.3 is only closely approximate to 3.4). The other is that the step variable can be changed inside the loop.