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



Users browsing this thread: 1 Guest(s)