User Tools

Site Tools


adding_20an_20event_20to_20the_20event_20queue

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
adding_20an_20event_20to_20the_20event_20queue [2018/03/31 13:19] – external edit 127.0.0.1adding_20an_20event_20to_20the_20event_20queue [2024/01/05 00:22] (current) – external edit 127.0.0.1
Line 1: Line 1:
 =====Adding an event to the event queue===== =====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:\\ +//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: 
 + 
 +<code bb4w> 
         SYS @fn%(18), handler%, msg%, wparam%, lparam%         SYS @fn%(18), handler%, msg%, wparam%, lparam%
         @flags% OR= &20000000         @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:\\ +</code> 
 + 
 +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: 
 + 
 +<code bb4w>
         handler%=!388 : REM ON TIME         handler%=!388 : REM ON TIME
         handler%=!396 : REM ON MOVE         handler%=!396 : REM ON MOVE
         handler%=!400 : REM ON SYS         handler%=!400 : REM ON SYS
         handler%=!404 : REM ON MOVE         handler%=!404 : REM ON MOVE
-(if no relevant **ON event** statement has yet been executed, or an **ON event OFF** has been executed, handler% will be set to zero).\\ \\  If you want to determine whether the event was successfully added to the queue you can test the return value:\\ +</code> 
 + 
 +(if no relevant **ON event** statement has yet been executed, or an **ON event OFF** has been executed, handler% will be set to zero).\\ \\  If you want to determine whether the event was successfully added to the queue you can test the return value: 
 + 
 +<code bb4w>
         SYS @fn%(18), handler%, msg%, wparam%, lparam% TO ok%         SYS @fn%(18), handler%, msg%, wparam%, lparam% TO ok%
         IF ok% @flags% OR= &20000000         IF ok% @flags% OR= &20000000
-If **ok%** is non-zero the event was added, if it is zero the queue was already full.\\ \\  Here is a simple example of the use of this technique:\\ +</code> 
 + 
 +If **ok%** is non-zero the event was added, if it is zero the queue was already full.\\ \\  Here is a simple example of the use of this technique: 
 + 
 +<code bb4w>
         ON SYS PRINT @msg%,@wparam%,@lparam% : RETURN         ON SYS PRINT @msg%,@wparam%,@lparam% : RETURN
  
Line 21: Line 35:
           WAIT 0           WAIT 0
         UNTIL FALSE         UNTIL FALSE
 +</code>
adding_20an_20event_20to_20the_20event_20queue.1522502344.txt.gz · Last modified: 2024/01/05 00:18 (external edit)