info = WaitEvent()
WaitEvent()function puts Hollywood in sleep state. The program will be woken up when an event is triggered. In this case
WaitEvent()will execute the function that you installed for this event and then it will return. Therefore, you always need to use
WaitEvent()in a loop. For example:
While quit = False WaitEvent Wend
Or use an endless loop:
Repeat WaitEvent Forever
WaitEvent() is a core function of the Hollywood language and you
should use one of the loops presented above in every script as your main
WaitEvent() has the advantage that it sleeps until an event is
triggered. This is important in a multitasking environment because it
saves CPU time. Never use polling loops as they will consume all CPU
time. If you need to constantly execute code in your main loop, use
SetInterval() to install an interval function that gets called
25 times a second by
The functions that
WaitEvent() will call when an event is triggered can
be installed with the following functions of the Hollywood event
library: MakeButton(), SetInterval(), SetTimeout(),
WaitEvent() must not be called from any callbacks executed by
WaitEvent(). In general, you should use
WaitEvent() only once in your
script: in your main loop. If you really have to check for events in a
callback executed by
WaitEvent(), use CheckEvents()
instead, but this should normally be unnecessary.
WaitEvent() returns a table that contains information about the callback
function it has just executed. The following fields will be initialized
in that table:
WaitEvent()returns without having run a callback, this field will be set to an empty string.
IDcan also be zero in case an event was caused that has no identifier associated.
WaitEvent()has executed a callback and then returned control to the script. If this is set to
False, then some other internal event has caused
WaitEvent()to return control to the script.
NResultsis greater than 0, this table will contain all values that the user callback returned. Otherwise this table will not be present at all. You can easily use this table to pass additional information from your callbacks back to the main scope of the program.