find named object and send it a message

Peter Nyboer's icon

I'm looking at some of the patcher scripting stuff in the api. iterator.c is a good guide, but I do want to check if there's a simple method similar to "getnamed" in javascript, such that I don't have to iterate through all the boxes in a patcher.
Something along the lines of

t_object *desiredobject = jpatcher_get_namedobject("scriptedname");

and you could then just pass desiredobject into the various jbox goodies.

P.

Emmanuel Jourdan's icon

Hey Peter,

You can do something like that:

t_max_err err;
t_object *patcher = NULL;
t_object *yourobject = NULL;

// get the patcher
err = object_obex_lookup(yourobjectpointer, gensym("#P"), &patcher);

// get the object that you're looking for.
yourobject = (t_object *)object_method(patcher, gensym("getnamedbox"), gensym("theobjectname"));

Peter Nyboer's icon

Great! Thanks EJ.

Peter