FutureBasic Logo

<<    Index    >> FutureBasic

delay   statement



Syntax
delay count

Description
This statement is an artifact of FB's heritage and is not recommended because it pauses the program's main thread for count milliseconds (a millisecond is a thousandth of a second). delay uses the system nanosleep() ( also not recommended ) call which attempts to deliver nanosecond accuracy. Please see Important Note below also.

count should be provided as either:
  1. inside a 4 byte integer ( SInt32 ) variable
  2. a literal integer
 
Example
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)


Important Note
The delay statement makes the main thread of your app wait, so your app users might notice macOS "beach balling"( or stuttering if you have a scrolling log, for example ) while delay runs. If you intend to implement a long delay (longer than a second in OS terms), consider writing code that doesn't block the main thread. Many CocoaUI calls offer an optional delay parameter which does NOT block the main thread.

See also
time; date; HandleEvents