How to get number of outlets ?

Jan 16, 2010 at 5:00pm

How to get number of outlets ?

Hello maxers,

To know how many outlets/inlets a patcher’s object have i do something like that :

t_object *ptr_o = NULL ;
t_object *ptr_b = NULL ;

ptr_b = jpatcher_get_firstobject (ptr_p) ;

while (ptr_b) {

if (ptr_o = jbox_get_object (ptr_b))
{
long a = object_attr_getlong (ptr_o, gensym (“numinlets”)) ;
long b = object_attr_getlong (ptr_o, gensym (“numoutlets”)) ;
}

ptr_b = jbox_get_nextobject (ptr_b) ;
}

everything is ok for UI objects,
but i always have ZERO ZERO for others (like [int], [trigger] etc …).

Has a thing there which I did not get ;-)
somebody would have an indication ?

Thanks a lot.

#47828
Jan 17, 2010 at 4:41pm

Hello maxers,

ok, it is not any more necessary to think ; i found the solution ; i do something like that :

ptr_b = jpatcher_get_firstobject (ptr_p) ;

while (ptr_b) {

t_symbol *s ;
long num_inlets ;
long num_outlets ;

s = object_classname (ptr_b) ;

if (s = gensym (“newobj”))
{
t_object *ptr_o = NULL ;
if (ptr_o = jbox_get_object (ptr_b))
{
s = object_classname (ptr_o) ;
}
}
num_inlets = object_attr_getlong (ptr_b, gensym (“numinlets”)) ;
num_outlets = object_attr_getlong (ptr_b, gensym (“numoutlets”)) ;

post (“%s / %ld %ld”, s->s_name, num_inlets, num_outlets) ;

ptr_b = jbox_get_nextobject (ptr_b) ;
}

BUT NOW, ANOTHER QUESTION :

to know if a box is UI or not, i tried that :

long why = class_is_ui (object_class (ptr_b)) ;

and Xcode don’t want to compile my code ;

/Developer/usr/bin/../libexec/gcc/i686-apple-darwin8/4.0.1/ld: Undefined symbols: _class_is_ui

it seems header is not good, but i include ext_obex.h !

#172023
Jan 19, 2010 at 1:26pm

This just means that the symbol is not exported. What should be able to do is get the box (the example projects show how to do this with #B) and then check the class of the box. If the class of the box is jnewobj then you know it is not a UI object.

Cheers

#172024
Jan 19, 2010 at 4:34pm

Hello Timothy,

that’s what i finally done (more or less) ; but just to learn, it should be great if you could post a short example of class_is_ui ( ) howto ; anyway doesn’t matter if you don’t have time.

Thanks a lot.

#172025

You must be logged in to reply to this topic.