One Event Style Per Program
Rule
Use exactly one event-handling style per program: setCallback()
handlers plus PROCESS_EVENTS for new code, or the older
SENDMSG/mnemonic style with a READ RECORD event loop for
existing code already written that way. Never introduce the mix into a program
without a strong, stated reason.
Why
PROCESS_EVENTS and a READ RECORD event loop on the
SYSGUI channel both block until an event arrives, and both pop the next event off
the same underlying queue. Mixed in one program, the two styles take each other's
events -- a callback silently never fires because the READ RECORD loop
already consumed its event, or vice versa. Switching between the two styles also
empties the event and notify queues, discarding whatever was already pending.
Edge
Existing code sometimes mixes the two styles already, usually the result of incremental changes over time rather than a deliberate design. When maintaining such a program, keep its existing style for the code being touched rather than converting it mid-file -- a partial conversion is exactly the mixed state this rule warns against.
Evidence
PROCESS_EVENTS Verb -- the
shared-queue behavior of PROCESS_EVENTS and a READ RECORD
event loop.
Example
The recommended style for new code -- one callback registration, then a
single PROCESS_EVENTS call:
btn!.setCallback(BBjAPI.ON_BUTTON_PUSH,"onPush") process_events onPush: print "pushed" return