isc_event_counts()

From InterBase
Jump to: navigation, search

Go Up to API Function Reference


Compares event parameter buffers (EPBs) to determine which events have been posted, and prepares the event parameter buffers for the next call to ­isc_que_events() or isc_wait_for_event().

Syntax

void isc_event_counts (
ISC_ULONG *result_array
short buffer_length,
char *event_buffer,
char *result_buffer);

Parameter Type Description

result_array

ISC_ULONG *

Contains the differences of the first 15 elements.

buffer_length

short

Length of the event parameter buffers, returned by the isc_event_block() call that allocated them

event_buffer

char *

Pointer to the event parameter buffer that specifies the event counts prior to the previous call to isc_wait_for_event() or isc_que_events()

result_buffer

char *

Pointer to the event parameter buffer filled in as a result of posting an event

Description

isc_event_counts() compares the event counts in the event parameter buffers, event_buffer and result_buffer, and sets up to the first 15 elements of result_array to contain the differences. It then modifies event_buffer to contain the same event counts as result_buffer in preparation for the next call to either isc_wait_for_event() or isc_que_events().

The counts in event_buffer specify how many times each event had been posted since the previous call to isc_event_wait() or isc_que_events(). The counts in result_buffer equal the values in event_buffer plus the number of additional times an event is posted after the current call to isc_event_wait() or isc_que_events(). If an event is posted after a call to either of these functions, its count is greater in result_buffer than in event_buffer. Other event counts may also be greater because an event may have been posted between calls to either of these functions. The values in status_array are the differences in values between event_buffer and result_buffer. This mechanism of comparing all the counts ensures that no event postings are missed.

Example

The following program fragment illustrates the set-up and waiting on any of the events named “DEC”, “HP”, or “SUN”, then calling isc_event_counts() to determine which events have been posted:

#include <ibase.h>
#define number_of_stocks 3;

char *event_buffer, *result_buffer;
ISC_result_array[20];
char *event_names[] = {"DEC", "HP", "SUN"};
long length;
int i;

length = isc_event_block( &event_buffer, &result_buffer, number_of_stocks,
"DEC", "HP", "SUN");
isc_wait_for_event( result_array,
&database_handle, /* Set by previous isc_attach_database(). */
length, /* Returned from isc_event_block(). */
event_buffer, result_buffer);
if (result_vector[0] == 1 && result_array[1]){
isc_print_status(status_vector); /* Display error message. */
return(1);
}

isc_event_counts(result_vector,(short) length, event_buffer, result_buffer);

for (i=0; i<number_of_stocks; i++)
if (result_vector[i]) {
/* The event has been posted. Do whatever is appropriate, for example,
 * initiating a buy or sell order. */
}

Return value

None.

See Also