FutureBasic Logo

<<    Index    >> FutureBasic 5

delay   statement

delay count

This statement causes program execution to pause for count milliseconds (a millisecond is a thousandth of a second). Delay uses the system nanosleep() call which attempts to deliver nanosecond accuracy.

count should be provided as either:
  1. inside a 4 byte integer ( SInt32 ) variable
  2. a literal integer
To pause a program for approximately 5 seconds, use the following code:       delay 5000

The following built-in constants are useful for producing delays of various durations:
_sec        = 1000  '(1 second)
_secHalf    = 500   '(1/2 second)
_seqQuarter = 250   '(1/4 second)
_secTenth   = 100   '(1/10 second)
_sec60th    = 17    '(about 1 tick)
_secTick    = 17    '(about 1 tick)

The delay statement makes the main thread of your app wait, so your app users might see OS X "beach balling" while delay is running. If you intend to implement a very long delay, consider writing code that doesn't block the main thread such as that written by Ken on the list 08-July-2017.

See Also:
timer; time$; date$; HandleEvents