equivalent of sendnamed in js


    Jul 01 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

    • Jul 02 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.
    • Jul 03 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.
      ----------------------------------------------------
    • Jul 03 2007 | 6:21 pm
      > There is more useful stuff like this for Litter Pros.
      Do you mean Litter Pro includes code examples?
      Mattijs
    • Jul 05 2007 | 4:10 pm
      Glad this helped.
      >Do you mean Litter Pro includes code examples?
      Yes.
      Not everyone wants or needs the source code, which is why this is an on-request thing.
      Best -- Peter