Event and File Serial Numbers

If you call outlet_int(), outlet_float(), outlet_list(), or outlet_anything() inside a Qelem or during some idle or interrupt time, you should increment Max’s Event Serial Number beforehand. More...

+ Collaboration diagram for Event and File Serial Numbers:

Functions

void evnum_incr (void)
 Increment the event serial number.
long evnum_get (void)
 Get the current value of the event serial number.
long serialno (void)
 Get a unique number for each Patcher file saved.

Detailed Description

If you call outlet_int(), outlet_float(), outlet_list(), or outlet_anything() inside a Qelem or during some idle or interrupt time, you should increment Max’s Event Serial Number beforehand.

This number can be read by objects that want to know if two messages they have received occurred at the same logical "time" (in response to the same event). Max increments the serial number for each tick of the clock, each key press, mouse click, and MIDI event. Note that this is different from the file serial number returned by the serialno() function. The file serial number is only incremented when patchers are saved in files. If more than one patcher is saved in a file, the file serial number will change but the event serial number will not.

Using Event Serial Numbers

Here is a Max patch that includes an object called simul that would use the information returned by evnum_get to return a 1 if the right and left inlets receive messages at the same time, 0 if not. The number boxes below show the results of clicking on the button objects or typing a key.

event_serialno.png

Function Documentation

long evnum_get ( void  )

Get the current value of the event serial number.

Returns:
The current value of the event serial number.
long serialno ( void  )

Get a unique number for each Patcher file saved.

This function returns a serial number that is incremented each time a Patcher file is saved. This routine is useful for objects like table and coll that have multiple objects that refer to the same data, and can embed the data inside a Patcher file. If the serial number hasn't changed since your object was last saved, you can detect this and avoid saving multiple copies of the object's data.

Returns:
The serial number.