equivalent of sendnamed in js

Jul 1, 2007 at 7:14pm

equivalent of sendnamed in js

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

#32707
Jul 2, 2007 at 5:01pm

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.

#108118
Jul 3, 2007 at 6:19pm

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.
—————————————————-

#108119
Jul 3, 2007 at 6:21pm

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

Do you mean Litter Pro includes code examples?

Mattijs

#108120
Jul 5, 2007 at 4:10pm
#108121

You must be logged in to reply to this topic.