Forums > Dev

equivalent of sendnamed in js

July 1, 2007 | 7:14 pm

Hi all, this must be a terribly basic question but what is the C equivalent of javascript’s sendnamed method?

I want to send a symbol to all like-named receive objects in a max patch from my external but I can’t seem to find anything about this in the docs.

Thanks in advance,
Matttijs


July 2, 2007 | 5:01 pm

You mean something like the following?

void
ForwardAnything(
Symbol* iRecip,
Symbol* iMsg,
short iArgC,
Atom iArgV[])

{
static Symbol* sSymThrough = NIL;

Object* thing = (Object*) iRecip->s_thing;

// Initialize our static symbol first time through
if (sSymThrough == NIL)
sSymThrough = gensym("through");

// Make sure we have a vaild thing
if (thing == NIL) return; // no good
if (thing->o_magic != MAGIC) return; // still no good
if (ob_class(thing)->c_sym != sSymThrough) return; // last check

// If we make it to here, we’re good to go
typedmess(thing, iMsg, iArgC, iArgV);

}

This is working, tested code. Sorry about the Forum formatting.

There is more useful stuff like this for Litter Pros.


July 3, 2007 | 6:19 pm

Wow Peter, that’s great! Thanks a lot, it works flawlessly.

Wouldn’t it be nice to include this in the docs, cycling?

Mattijs

Quote: Peter Castine wrote on Mon, 02 July 2007 19:01
—————————————————-
> You mean something like the following?
>
> void
> ForwardAnything(
> Symbol* iRecip,
> Symbol* iMsg,
> short iArgC,
> Atom iArgV[])
>
> {
> static Symbol* sSymThrough = NIL;
>
> Object* thing = (Object*) iRecip->s_thing;
>
> // Initialize our static symbol first time through
> if (sSymThrough == NIL)
> sSymThrough = gensym("through");
>
> // Make sure we have a vaild thing
> if (thing == NIL) return; // no good
> if (thing->o_magic != MAGIC) return; // still no good
> if (ob_class(thing)->c_sym != sSymThrough) return; // last check
>
> // If we make it to here, we’re good to go
> typedmess(thing, iMsg, iArgC, iArgV);
>
> }
>
>
> This is working, tested code. Sorry about the Forum formatting.
>
> There is more useful stuff like this for Litter Pros.
—————————————————-


July 3, 2007 | 6:21 pm

> There is more useful stuff like this for Litter Pros.

Do you mean Litter Pro includes code examples?

Mattijs



Viewing 5 posts - 1 through 5 (of 5 total)