next_event, next_event_nb

next_event, next_event_nb — wait for an event and call the event handling function.

Syntax

next_event ()
next_event_nb ()

		

Arguments

none

Returns

The result of executing the next event. If no event was processed, next_event_nb will return undefined, and next_event will not return.

Description

next_event blocks, waiting for an event from: a window system (where applicable), another task (an interprocess communication message), a timer, or a signal. An event handling function is automatically called if one has been defined for the event. The result of next_event is the result returned from the event handler, or nil if no event handler had been defined.

next_event_nb behaves exactly like next_event, except that next_event_nb (nb stands for non-blocking) returns immediately with undefined if no event is waiting to be processed.

Example

1. Here is the simplest use of next_event, causing Gamma to wait for and process the next event.

Gamma> while(t) next_event();

2. This program does basically the same thing, creating a main loop for program event processing, but it features error protection as well.

while (t)
{
	try
	{
		next_event();
	}
	catch
	{
		princ("last error: ", _last_error_," calling stack: ",
			stack(),"\n");
	}
}