While within while query
BlitzMax Forums/BlitzMax Beginners Area/While within while query
| ||
I have the following code that doesn't exit when I hit ESCAPE.It should quit when Escape is hit but it doesn'.It's a while loop within a while loop.It appears that the second while loop takes over and the code doesn't check for the escape key.Is this the correct way for while to behave.Shouldn't blitz check the first while loop continually ? Graphics 800,600 text$=" test....................................................................." While Not KeyHit(KEY_ESCAPE) While x <=20000 Cls DrawText text,tickerx#,260 If MilliSecs() > FrameTimer + 100 FrameTimer = MilliSecs() frame:+1 EndIf x :+ 1 tickerx=tickerx-5 Flip Wend wend |
| ||
Yeah that's the correct behaviour, you'd need to check for the keypress within the embedded loop aswell |
| ||
Change it to:Graphics 800,600 strict text$=" test....................................................................." local exit:byte #mainloop repeat While x <=20000 Cls DrawText text,tickerx#,260 If MilliSecs() > FrameTimer + 100 FrameTimer = MilliSecs() frame:+1 EndIf x :+ 1 tickerx=tickerx-5 Flip if keyhit(key_escape) exit mainloop endif Wend forever |