For Next Looping

Blitz3D Forums/Blitz3D Beginners Area/For Next Looping

Mental Image(Posted 2004) [#1]
For x=0 to 7
;do nothing but whistle
next

Print x

--------------------

X now equals 8. WHY???


_PJ_(Posted 2004) [#2]
X will increment each loop as required. When it reaches 7, it wil;l 'Do nothing but whistle' then, the program reaches the NEXT command, and looks back at the FOR command, incrementing to 8. It sees the TO 7, so skips to the end of the loop. The FOR/NEXT will not action on a value of 8, but X has incremented anyway. It's perfectly normal ;)


Mental Image(Posted 2004) [#3]
Makes sense, I just got caught out falling through the loop and expected x to be 7.

ta,

Paul