Changes

Jump to: navigation, search

The Queue of Events

1,158 bytes added, 16:45, 21 June 2017
Processing Events
= Processing Events =
 
In [https://en.wikipedia.org/wiki/Event-driven_programming Event-driven programming] the readmain loop of a program
takes care of fetch, process and/or dispatch incoming events, the following code is an example of a minimal one.
 
<syntaxhighlight lang="pawn" line>
/***************************************************************
*
* Minimal Event Processing Loop
*
* program.p
*
***************************************************************/
 
// include the library for H6105-D
//
#include <hydlib_cp>
 
// main function
//
main()
{
// clear display
//
dClear();
// select system font
//
dFont( system5x7 );
 
// place cursor
//
dCursor( 0, 0 );
// print on display
//
dPrintf("Processing Events");
 
// declare an event container
//
new BASE_EVENT(ev);
 
// enable system events
//
SysEvEnable();
// main loop
//
for( ;; )
{
// get new event from queue
//
EventGet( ev );
// process some events
//
switch( ev.opcode )
{
// script stop command
//
case SevEmergExit:
{
break;
}
 
// push button
//
case SevDinActive:
{
}
}
}
 
// program end
}
</syntaxhighlight>

Navigation menu