News:

Building a 3D Ray Tracer  By stevmjon

Main Menu

Wait Seconds without using Timer

Started by kevin, February 10, 2023, 05:15:46 AM

Previous topic - Next topic

kevin


    Wait Seconds without using Timer

   This function will wait an approximate number of seconds for the user.   It does this by polling the CurrentTime$() function in a loop until it changes.   Each time i changes we know that one second has passed.  So if we call repeat this process X number of times our program will wait X number of seconds.   


PlayBASIC Code: [Select]
   print CurrentTime$()
Sync
WaitSeconds(10)

print CurrentTime$()

Sync
waitkey



Function WaitSeconds(NumberOfSeconds)

for lp=1 to NumberOfSeconds
local t$=currenttime$()
repeat
wait 10
until t$ <>currenttime$()
wait 500
next
EndFunction






      PLayBASIC Documentation

      - CurrentTime$()
      - Timer()
      - Wait