Max maintains a symbol table of all strings to speed lookup for message passing. More...
|The symbol. More...|
|t_symbol *||gensym (C74_CONST char *s)|
|Given a C-string, fetch the matching t_symbol pointer from the symbol table, generating the symbol if neccessary. |
|t_symbol *||gensym_tr (const char *s)|
|Given a C-string, fetch the matching t_symbol pointer from the symbol table, generating and translating the symbol if neccessary. |
Max maintains a symbol table of all strings to speed lookup for message passing.
If you want to access the bang symbol for example, you’ll have to use the expression gensym("bang"). For example, gensym() may be needed when sending messages directly to other Max objects such as with object_method() and outlet_anything(). These functions expect a t_symbol*, they don’t gensym() character strings for you.
The t_symbol data structure also contains a place to store an arbitrary value. The following example shows how you can use this feature to use symbols to share values among two different external object classes. (Objects of the same class can use the code resource’s global variable space to share data.) The idea is that the s_thing field of a t_symbol can be set to some value, and gensym() will return a reference to the Symbol. Thus, the two classes just have to agree about the character string to be used. Alternatively, each could be passed a t_symbol that will be used to share data.
Storing a value:
Retrieving a value:
|t_symbol* gensym||(||C74_CONST char *||s||)|
|t_symbol* gensym_tr||(||const char *||s||)|