@attribute questions

Sep 1, 2011 at 5:54pm

@attribute questions

Hey everyone,

Another probably easy question for someone who knows how to read the docs… I just can’t find the info I need or if I did find it, I don’t know that I did :(

Ok, so I have an object for which I would like more than 1 @attribute.

I use the following to setup the args for the inspector:

CLASS_ATTR_LONG(c, "mode", 0, t_MRattrTest, mode);			//adds inspector support and attribute to object
	CLASS_ATTR_STYLE_LABEL(c, "mode", 0, "enumindex", "Mode");	//add text support to inspector
	CLASS_ATTR_ENUMINDEX(c, "mode", 0, ""int" "float"");	// text that is to be used in the inspector
	CLASS_ATTR_FILTER_CLIP(c, "mode", 0, 1);
	CLASS_ATTR_SAVE(c,"mode", 0);								//if attribute is set in inspector and NOT typed into the object it is saved	

        CLASS_ATTR_LONG(c, "area", 0, t_MRattrTest, area);
	CLASS_ATTR_STYLE_LABEL(c, "area", 0, "enumindex", "Area");
	CLASS_ATTR_ENUMINDEX(c, "area", 0, ""Off" "On"");
	CLASS_ATTR_FILTER_CLIP(c, "area", 0, 1);
	CLASS_ATTR_SAVE(c,"area", 0);

In my _new(…) routine I then use attr_args_process(x, argc, argv);

That seems to work fine for the first attribute, but not the second or third (specially if the arguments are typed in in a different order than they were implemented). How do I implement several @-style attributes? Is there a convenience function or do I have to do it manually?
I thought maybe attr_args_offset() would be of help, but it only gives me the first instance of an @attribute and if arguments and @attributes are mixed that doesn’t work anymore…

I did read the “Sending Messages, Calling Methods” part of the docs, but am none-the-wiser… where can I read up on this? any code examples I could study.

Thanks for any pointers!!

#58720
Sep 2, 2011 at 5:54am

Hello MIB,

there is nothing to do more than you did ; sadly the “attrtester.c” in sdk examples use another method (dictionary) ; you should have a mistake somewhere else …

… i joined an example you could study ;-)

HTH

Attachments:
  1. flop.c
#211087
Sep 2, 2011 at 6:07pm

Hi vanille,

Thanks so much!! Yours works like a charm. I knew I was missing something simple. By the look of it, the only difference in your code to mine is that in my _new(…) routine I don’t do this:

t_flop *x = NULL;

	if (x = (t_flop *)object_alloc (flop_class))
		{
			x->leftOutlet = bangout ((t_object *)x);

			attr_args_process (x, argc, argv);
		}

I allocate the object straight away… once I added the above code it works perfectly. THANKS!!

#211088

You must be logged in to reply to this topic.