Adding an event to the event queue

by Richard Russell, August 2014

Normally, event interrupts (e.g. ON MOUSE, ON MOVE, ON SYS and ON TIME) take place as a result of user actions such as mouse clicks, menu selections, moving/re-sizing a window or (in the case of ON TIME) periodically. The events are initially added to a 32-event FIFO queue, and then automatically dispatched to the specified BASIC handler routine (if any).

For test purposes, or other special uses, it is possible to insert a 'pseudo event' into the queue (if there is enough space). You can do that using the following code:

SYS @fn%(18), handler%, msg%, wparam%, lparam%
@flags% OR= &20000000

Here handler% is the address of the event handler (see below), msg% is the value which will ultimately be received by the handler in the @msg% system variable, wparam% is the value which will be received in @wparam% and lparam% is the value which will be received in @lparam%.

The handler% parameter can be the address of a custom handler or can specify one of the standard ON… event handlers as follows: