Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Updating Clock at a different rate to program loop-example not working as expected?
#1
Hi All,
I hope this is an easy one for someone to point out my mistake.  However I did find some reference to timer behaviour in windows that was different to Linux, so I tried this in Fedora, but both OSs ran the same.  I found this example (I've modified it for QB64 timer only - didn't work as I expected with 'legacy' timer either).  I expected that the clock would update at a rate of once per second, but that the A would be printed every 6 seconds (due to the sleep). However, if you run it the print A occurs every timer tick.  What am I missing?  Thanks!

Code: (Select All)
$Debug
timerhandle% = _FreeTimer
Timer(timerhandle%) On ' enable timer event trapping
Screen 0
Locate 4, 2 ' set the starting PRINT position
On Timer(timerhandle%, 1) GoSub Clock ' set procedure execution repeat time
Rem Sleep
Do While InKey$ = "": Print "A";: Sleep 6: Loop
Timer Off
System

Clock:
row = CsrLin ' Save current print cursor row.
col = Pos(0) ' Save current print cursor column.
Locate 2, 37: Print Time$; "    "; Date$ ' print current time at top of screen.
Locate row, col ' return to last print cursor position
Return
Reply


Messages In This Thread
Updating Clock at a different rate to program loop-example not working as expected? - by dowster - 08-15-2024, 11:50 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Exiting sub while inside a loop PhilOfPerth 5 510 12-05-2025, 09:40 AM
Last Post: PhilOfPerth
  plotting shapes not working madscijr 6 623 10-22-2025, 05:29 AM
Last Post: SMcNeill
  why isn't _FULLSCREEN working? madscijr 5 510 09-20-2025, 01:47 AM
Last Post: SMcNeill
  Do Loop, Sleep and Mouse Button Dimster 5 584 09-06-2025, 12:57 PM
Last Post: Dimster
  Using modulo to loop through lists fistfullofnails 3 709 09-03-2025, 11:50 PM
Last Post: fistfullofnails

Forum Jump:


Users browsing this thread: 1 Guest(s)