calling methods from another object

    Oct 07 2009 | 3:58 pm
    If anyone can help with the following....
    I am trying to send a message from one object to another;
    In my sending object I have the code;
    atom_setlong(x->pparray, f);
    object_method_typed(x->boundobject, gensym("tester"), 1, x->pparray, &rv);
    and have also tried;
    object_method_long(x->boundobject, gensym("tester"), f, &rv);
    (boundobject is pointer to receiving object, f is long value).
    In my receiving object I have the prototype -
    void lh_trkmtx_tester(t_lh_trkmtx *x, long n);
    and in main -
    class_addmethod(c, (method)lh_trkmtx_tester, "tester",A_LONG, 0);
    and the function -
    void lh_trkmtx_tester(t_lh_trkmtx *x, long n)
    post("message %i", n);
    return ;
    When testing I always receive the following in the max window everytime the sending method is triggered;
    lh_trkmtx : doesn't understand "tester"
    When I create a message box to send the message in via inlet1 all works fine.
    Am I trying to do something that you cannot do, or am I missing something obvious?
    I successfully use the same method to send a "set" value message to a dial object,
    Any help or enlightenment on this would be greatly appreciated... I 'think',,,.. this is my last programming stumbling block!
    Kind Regards,

    • Oct 08 2009 | 12:06 pm
      If anyone else comes across the same confusion, .... arranging the code like below in the sending object makes all work just fine -
      atom_setsym(x->pparray, gensym("tester"));
      atom_setlong(x->pparray+1, f);
      object_method_typed(x->boundobject, gensym("message"), 2, x->pparray, &rv);