lang • wait


WAIT [ Delay ]

Call the event loop recursively.

If Delay is specified, the function does not return until Delay seconds elapse.

If Delay is not specified, the function processes all pending events and returns immediately. In that specific case, input events (keyboard and mouse) are ignored.

Delay is a floating point number. So, if you want to wait 100 ms, just do:

Wait 0.1


Since 3.15


Call the event loop recursively, and waits until at least one event is processed.


' Waits a little, letting the user interacts with the GUI
Wait 0.05

' Waits, but the user can just watch what happens...

If you call WAIT from an event handler, you may create infinite recursions, and then stack overflows.

For example, look at the following code:

PUBLIC SUB MySerialPort_Read()

  DIM sData, sTemp AS String
  DIM iTries AS Integer

  FOR iTries = 1 TO 5
    ' wait a bit and read response.
    WAIT 0.01
    ' see if we got some data.
    READ #LAST, sTemp, Lof(LAST)
    sData &= sTemp


WAIT is called without reading anything on the serial port. So it is yet ready for being read, and the Read event is raised recursively again and again until the stack is full.

In that case, you can solve the problem by using the SLEEP instruction instead.

See also