HTBasic Help
×
Menu
Index

WAIT FOR EVENT

Suspends program execution until an event occurs.
 

Example

WAIT FOR EVENT
WAIT FOR EVENT; TIMEOUT 30
 

Syntax

 
WAIT FOR EVENT [ ;TIMEOUT timeout_value ]
 
Item
Description
Range
timeout_value
wait up to this many seconds for user input, then resume program execution
to any non-negative number
 

Description

WAIT FOR EVENT suspends program execution until a specified event occurs. When an enabled event occurs, WAIT FOR EVENT terminates and the event triggers the appropriate pending ON EVENT statement. If no events are currently defined, WAIT FOR EVENT returns immediately.
 
WAIT FOR EVENT will wait indefinitely for an event unless a TIMEOUT value (in seconds) is specified after which program execution resumes if no enabled events occur. The corresponding branch may or may not be taken, depending on whether the current or defining context has priority.
 
_WAIT FOR EVENT will wait if any events are defined, even if disabled or associated with widgets that are not visible. If the widgets are not visible, WAIT FOR EVENT will terminate only if the timeout period is reached, or if you press the Stop or Reset key.
 
For example, the following lines allow the program to loop continuously, which allows the computer to do other things while waiting for the event to occur.
 
LOOP
   WAIT FOR EVENT
END LOOP
 
Since the WAIT FOR EVENT statement suspends program execution, the computer is free to service other processes as opposed to the following which ties up the processor:
 
10 GOTO 10