08-15-2024, 11:50 AM
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!
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