While Keyhit waiting problems

BlitzMax Forums/BlitzMax Beginners Area/While Keyhit waiting problems

Hi,
I have code that I want only to exit if the user presses the ESX button.So I have a main loop like so:
While NOT KeyHit(KEY_ESCAPE)
c64(MilliSecs())
Wend

This is fine but each of these functions contain while loops and while these loops are running pressing the escape key does nothing.Am I missing something here ?

Graphics 800,600,0
HideMouse
While NOT KeyHit(KEY_ESCAPE)
   c64(MilliSecs())
   fade()
   SnowFlake(MilliSecs())
Wend

'-----------------------------------------'

Function c64(timerval:Int)
  While timerval+15000 > MilliSecs()
	  Cls
       
 Local y=0,h
        Repeat
                h=Rand(5,60)
                SetColor Rand(255),Rand(255),Rand(255)
                DrawRect 0,y,GraphicsWidth(),h
                y:+h
        Until y>=GraphicsHeight()
	  Flip
  Wend
End Function




Your code runs as expected... Remember that your C64 loop is 15 seconds long. If you hit the escape key and wait 15 seconds the program ends.

In your C64 Loop maybe just use something simple like
Function c64(timerval:Int)
  While timerval+15000 > MilliSecs()
	  Cls
       
 Local y=0,h
        Repeat
                h=Rand(5,60)
                SetColor Rand(255),Rand(255),Rand(255)
                DrawRect 0,y,GraphicsWidth(),h
                y:+h
        Until y>=GraphicsHeight()
	  Flip
         If KeyHit(KEY_ESCAPE) Then End  '<-------------------------------
  Wend
End Function


{cut}
do what prvious post said

His code is adding 15000 millisecs not 1500.

15000 Millisecs is 15 seconds vs 1.5 seconds.

I know,my mistake

:)

Thanks.