User Tools

Site Tools


using_20the_20eventlib_20library

Differences

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

Link to this comparison view

using_20the_20eventlib_20library [2018/03/31 13:19]
127.0.0.1 external edit
using_20the_20eventlib_20library [2018/04/17 19:22] (current)
tbest3112 Added syntax highlighting
Line 6: Line 6:
 ==== PROC_eventregister(WM_xxxx,​ PROChandler()) ==== ==== PROC_eventregister(WM_xxxx,​ PROChandler()) ====
  This registers a procedure to be called when the specified event occurs; the event is identified by its @msg% value. PROC_eventregister can be called multiple times with the same event identifier, in which case all the specified handlers will be called sequentially. The handler needs to be defined to receive three parameters as follows:​\\ ​  This registers a procedure to be called when the specified event occurs; the event is identified by its @msg% value. PROC_eventregister can be called multiple times with the same event identifier, in which case all the specified handlers will be called sequentially. The handler needs to be defined to receive three parameters as follows:​\\ ​
 +<code bb4w>
         DEF PROChandler(msg%,​ wparam%, lparam%) ​         DEF PROChandler(msg%,​ wparam%, lparam%) ​
 +</​code>​
 \\  \\ 
 ==== PROC_eventpoll ==== ==== PROC_eventpoll ====
  This simply polls the queue to see if any events are pending, and if so calls their registered handlers (if any) in the sequence in which the events occurred. If multiple handlers are registered for an event, they are all called (the last one registered is called first). Typically a program will wait in a polling loop such as:\\   This simply polls the queue to see if any events are pending, and if so calls their registered handlers (if any) in the sequence in which the events occurred. If multiple handlers are registered for an event, they are all called (the last one registered is called first). Typically a program will wait in a polling loop such as:\\ 
 +<code bb4w>
         REPEAT         REPEAT
           PROC_eventpoll           PROC_eventpoll
           WAIT 0           WAIT 0
         UNTIL FALSE          UNTIL FALSE 
 +</​code>​
 \\  If you need to be informed that the event queue overflowed, you can register a handler for that by specifying an event ID of zero:​\\ ​ \\  If you need to be informed that the event queue overflowed, you can register a handler for that by specifying an event ID of zero:​\\ ​
 +<code bb4w>
         PROC_eventregister(0,​ PROCoverflow()) ​         PROC_eventregister(0,​ PROCoverflow()) ​
 +</​code>​
 \\  Despite the library'​s simplicity it is quite powerful, and goes a long way to solving the problem of distributing events to multiple handlers (potentially in multiple libraries) and ensuring they are called synchronously. It is designed to use only a small amount of memory.\\ \\  Here's a simple test program illustrating its use:​\\ ​ \\  Despite the library'​s simplicity it is quite powerful, and goes a long way to solving the problem of distributing events to multiple handlers (potentially in multiple libraries) and ensuring they are called synchronously. It is designed to use only a small amount of memory.\\ \\  Here's a simple test program illustrating its use:​\\ ​
 +<code bb4w>
         WM_MOVE = 3         WM_MOVE = 3
         WM_SIZE = 5         WM_SIZE = 5
Line 64: Line 71:
         DEF PROCoverflow(M%,​ W%, L%)         DEF PROCoverflow(M%,​ W%, L%)
         PRINT "Event queue overflowed!!"​         PRINT "Event queue overflowed!!"​
-        ENDPROC ​+        ENDPROC 
 +</​code>​
using_20the_20eventlib_20library.txt · Last modified: 2018/04/17 19:22 by tbest3112