Skip to content

Sys.SetTimeout

boxgaming edited this page Jul 11, 2026 · 2 revisions

Sets a timer which executes a function or sub once the timer expires.
Available in release 0.11.0

Syntax

Sys.SetTimeout fnCallback [, delay%]

Parameters

  • The fnCallback parameter is a reference to the function or sub which will be executed after the timer expires.
  • The optional delay parameter is a non-negative integer indicating how long the timer should wait before the specified function or sub is executed, in milliseconds. Defaults to 0 if not specified.

Example

Import Sys From "lib/lang/system.bas"

Sys.SetTimeout @CheckTime, 1000

Print "Press ESC to exit..."
While _KeyHit <> 27
    _Limit 60
WEnd
Print "End of main code"

Sub CheckTime
    Print Sys.IsRunning; ": "; Sys.TimeInMillis
    
    If Sys.IsRunning Then 
        Sys.SetTimeout @CheckTime, 1000
    End If
End Sub

Output

Print ESC to exit...
 -1: 1783779913478
 -1: 1783779914480
 -1: 1783779915481
 -1: 1783779916484
 -1: 1783779917486
End of main code
 0: 1783779918487

See Also

Dom.RequestAnimationFrame
Sys.TimeInMillis
JavaScript - window.setTimeout()

Clone this wiki locally