Function: ScheduleHerevent Purpose: Register a function to be called whenever Hermes generates an event meeting a specified mask. Category: SYSTEM File: herevents.c Author: J.P. Terlouw Use: #include "herevents.h" ident id; id = ScheduleHerevent(proc, mask, arg); HereventProc proc - pointer to function int mask - event mask: the bitwise OR of any of the events defined in taskcom.h void *arg - 'client' data Description: ScheduleHerevent registers a function to be called by MainLoop (or by another event loop to wich event handling has been delegated) whenever Hermes generates an event which meets the specified mask. In this call, 'arg' will be passed to 'proc'. The return value is a unique identification code corresponding with the registration, which will also be passed as an argument to 'proc'. The prototype of 'proc' is: void proc(ident id, Event event, void *arg); The argument 'event' has the generic Hermes event type. Within 'proc' this should be cast to one or more specific event types. Example: The following program illustrates how the function can be used. #include "stdio.h" #include "cmain.h" #include "gipsyc.h" #include "init.h" #include "finis.h" #include "anyout.h" #include "herevents.h" static char message[80]; static fint zero=0; static void handle_key(ident id, Event event, void *arg) { KeyEvent keyevent=(KeyEvent)event; sprintf(message,"%s: %s", (char*)arg, keyevent->key); anyout_c(&zero,tofchar(message)); } static void handle_resume(ident id, Event event, void *arg) { ResEvent resevent=(ResEvent)event; anyout_c(&zero,tofchar("Resume after pause")); } static void handle_any(ident id, Event event, void *arg) { anyout_c(&zero,tofchar("Keychange or resume (only one message)")); DescheduleHerevent(&id); } MAIN_PROGRAM_ENTRY { init_c(); (void)ScheduleHerevent(handle_key, KEYCHANGE, "Keyword changed"); (void)ScheduleHerevent(handle_resume,RESEVENT,NULL); (void)ScheduleHerevent(handle_any,KEYCHANGE|RESEVENT,NULL); MainLoop(); finis_c(); return 0; } Related Docs: DescheduleHerevent.dc3, events.dc3 Updates: Apr 8, 1997: JPT, Document created.