Page 2 of 2
Posted: Thu May 14, 2009 11:00 pm
by Kaeru Gaman
well ok, I'm convinced that it is not bottom-controlled.
but
Code: Select all
LStart = 10
LStop = 20
LStep = -1
LCount = LStart
While LCount >= LStart And LCount <= LStop ; For LCount = 10 To 20 Step -1
Debug "Step " + Str(LCount) + ", clap your hands!"
LCount + LStep ; Next
Wend
Top Controlled, next step at the end....
executed at least once.
Posted: Thu May 14, 2009 11:16 pm
by Mahan
Top Controlled, next step at the end....
executed at least once.
Agree 100%. That's what I meant when I wrote:
... a while..wend type loop are very easy to rig for 1 single forced run-through ...
In the end it's clearly a matter of tastes (as some already noted), but it's easy to adapt PB to do what we want it to anyways
edit: or more correctly "adapt our code to PB so it does what we want."
Posted: Thu May 14, 2009 11:35 pm
by Kaeru Gaman
I just wanted to discuss what should be called basic behaviour of a For-Loop.
skipping the first execution when the Iteration does not meet the Interval, is an additional feature.
ts gave a good example. same applies in stepping thru a string.
it's really handy, it increases the usability of the For-Loop, I really like it.
but it's no basic behaviour, it's an additional feature.
Posted: Fri May 15, 2009 8:29 am
by djes
Mahan wrote:
Maybe it's a matter of habit but I almost never write repeat..until loops anymore. I only use while..wend, for..next and foreach..next loops.
I almost never use While...Wend loops

Maybe because I have the ASM habit, generally the test is after the code to avoid a jump.
Posted: Sun May 17, 2009 12:04 pm
by Psych
Interesting...
As an old VB programmer I cannot think of a single time I didn't need to check the values first when using for next loops with non-static values, so I am in favour of the way PB handles them, it's less steps for the programmer, IMHO. Classic basic never checked if the 'range' was invalid and so always iterated once, meaning you could execute once even if the end condition was met (or exceeded).
As for While and Repeat, this is why we have them both, I am guessing, so we can decide whether to check before or after the code block, it's all about preference and how your particular program flow is configured.
In summary, I prefer this 'pre-loop' checking on For loops, makes more sense to me.