ON EVENT |
![]() ![]() |
ON EVENT GOTO label
This declares an MyBASIC2 event handler. Events can be raised by using the EVENT statement or by extension libraries. Use EVENTID to identify the event. If EVENTID returns 0, then there are no more events.
Example:
OPTION EXPLICIT ON
ON EVENT GOTO _HANDLER
EVENT 1 EVENT 2
IF EVENTID = 0 THEN PRINT "Happy Dance...No More Events!", ELSE PRINT "We still have EVENT ";EVENTID;" to process", ' Remove any unprocessed events EVENT 0 IF EVENTID <> 0 THEN PRINT "More EVENTS ???", ELSE PRINT "OK, No more...", ENDIF ENDIF
PRINT,
END
_HANDLER: PRINT "%EVENT, ID: ";EVENTID, RESUME NEXT
|