<?xml version="1.0" encoding="UTF-8"?>
	<rss version="2.0"
		xmlns:content="http://purl.org/rss/1.0/modules/content/"
		xmlns:wfw="http://wellformedweb.org/CommentAPI/"
		xmlns:dc="http://purl.org/dc/elements/1.1/"
		xmlns:atom="http://www.w3.org/2005/Atom"

			>

	<channel>
		<title>Cycling 74  &#187;  Topic: umenu &#8211; symbol value</title>
		<atom:link href="http://cycling74.com/forums/topic/umenu-symbol-value/feed" rel="self" type="application/rss+xml" />
		<link>http://cycling74.com/forums/topic/umenu-symbol-value/feed</link>
		<description></description>
		<pubDate>Tue, 18 Jun 2013 23:09:45 +0000</pubDate>
		<generator>http://bbpress.org/?v=2.2.4</generator>
		<language></language>

		
														
					
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-65199</guid>
					<title><![CDATA[umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-65199</link>
					<pubDate>Tue, 13 Nov 2012 15:34:14 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>Hey,</p>
<p>I&#8217;d like to get the value of a umenu as a symbol.<br />
I can get the value index with object_getvalueof() but didn&#8217;t manage to get the symbol value.<br />
I tried several things with object_attr&#8230; which didn&#8217;t work. </p>
<p>Greetings,<br />
Alex</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234972</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234972</link>
					<pubDate>Tue, 13 Nov 2012 16:23:54 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p>You can look for the items attribute and extra the symbol from there.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234973</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234973</link>
					<pubDate>Tue, 13 Nov 2012 20:58:13 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks, but somehow I can&#8217;t get it working.</p>
<p>I tried:</p>
<p>void notify(t_iterator *x, t_symbol *s, t_symbol *msg, void *sender, void *data)<br />
{<br />
    long a1 = 1; t_atom* rv = NULL;<br />
    object_getvalueof(sender, &#038;a1, &#038;rv);<br />
    long value = atom_getlong(rv);<br />
    post(&#8220;%i value&#8221;, value); //index value is correct</p>
<p>    //I&#8217;d like to get this working for arrays I don&#8217;t know the size of before<br />
    //This only produces a,b,c,d &#8230;etc. analog to the indices 0,1,2,3 &#8230; for any values in the umenu</p>
<p>    long a2 = 1; t_symbol* item_list = NULL;<br />
    object_attr_getsym_array(sender, gensym(&#8220;items&#8221;), a2, &#038;item_list);<br />
    t_symbol* name = &#038;item_list[atom_getlong(rv)];</p>
<p>    post(&#8220;%s&#8221;, name->s_name);</p>
<p>}</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234974</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234974</link>
					<pubDate>Tue, 13 Nov 2012 22:51:13 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p>You need to ask the current value of the items attribute so that should be something more or less like this (forum coding):</p>
<pre><code>t_object *attr = object_attr_get(apointertotheumenuobject, gensym("items");
if (attr) {
	long ac = 0;
 	t_atom *av = NULL;
	object_attr_getvalueof(apointertotheumenuobject, attr, &#038;ac, &#038;av);
	if (ac &#038;&#038; av) {
		... do something with it;
		sysmem_freeptr(av);
	}
}</code></pre>						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234975</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234975</link>
					<pubDate>Tue, 13 Nov 2012 23:04:34 +0000</pubDate>
					<dc:creator>Luigi Castelli</dc:creator>

					<description>
						<![CDATA[
						<p>I coded this from the top of my head without testing it so use it with caution.<br />
(&#8216;sender&#8217; should be a pointer to the umenu object)</p>
<pre><code>void notify(t_iterator *x, t_symbol *s, t_symbol *msg, void *sender, void *data)
{
    long ac = 0;
    t_atom *av = NULL;
    long index;

    object_getvalueof(sender, &#038;ac, &#038;av);
    if (av) {
        index = atom_getlong(av);
        post("%i", index); //index value is correct
        sysmem_freeptr(av);

        ac = 0;
        av = NULL;
        object_attr_getvalueof(sender, gensym("items"), &#038;ac, &#038;av);
        if (av) {
            name = atom_getsym(av + index);
            post("%s", name->s_name);
            sysmem_freeptr(av);
        }
    }

    //I&#39;d like to get this working for arrays I don&#39;t know the size of before
    //This only produces a,b,c,d ...etc. analog to the indices 0,1,2,3 ... for any values in the umenu
}</code></pre><p>Let me know if it works&#8230;</p>
<p>- Luigi</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234976</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234976</link>
					<pubDate>Wed, 14 Nov 2012 15:42:11 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>Thanks for the given ideas!&#8230;but it still does not work.</p>
<p>This time I tried:</p>
<p>void notify(t_iterator *x, t_symbol *s, t_symbol *msg, void *sender, void *data)<br />
{<br />
    long ac = 0;<br />
    t_atom *av = NULL;<br />
    t_symbol* name = NULL;<br />
    long index;</p>
<p>    object_getvalueof(sender, &#038;ac, &#038;av);<br />
    if (av)<br />
    {<br />
        index = atom_getlong(av);<br />
        post(&#8220;%i&#8221;, index); //index value is correct</p>
<p>        ac = 0;<br />
        av = NULL;<br />
        object_attr_getvalueof(sender, gensym(&#8220;items&#8221;), &#038;ac, &#038;av);<br />
        if (av)<br />
        {<br />
//            t_symbol* name = atom_getsym(av + index); //only gets the value at index 0 correctly<br />
            name = atom_getsym(&#038;av[index]);   //only gets the value at index 0 correctly<br />
            post(&#8220;%s umenu value&#8221;, name->s_name);<br />
        }<br />
    }<br />
    sysmem_freeptr(av);<br />
    sysmem_freeptr(name);<br />
}</p>
<p>As mentioned in the comments like this I can get the first value correctly but no ones greater than 0. </p>
<p>Greetings,<br />
Alex</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234977</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234977</link>
					<pubDate>Wed, 14 Nov 2012 15:46:13 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>BTW: Is it a good habit to free ALL max local variables like this at the end of a function?</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234978</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234978</link>
					<pubDate>Wed, 14 Nov 2012 16:35:19 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p>It&#8217;s a good idea to free the memory that have been allocated ;-)</p>
<p>It looks like your problem is that you don&#8217;t get to ask the values on the correct object/attribute.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234979</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234979</link>
					<pubDate>Thu, 15 Nov 2012 14:00:55 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>&#8230;I started learning C just recently, doing mainly Java before. So, I&#8217;ll do that, thanks, :D</p>
<p>But I think if it would the wrong object/attr I would not always get the correct values for index 0.<br />
So if I put &#8220;max is great&#8221; at index 0 the post function [post("%s umenu value", name->s_name)] shows exactly that string in the max console.<br />
Anyway it&#8217;s not too bad for me to only work with the indices instead of strings. I&#8217;ll stick to that.</p>
<p>Greetings,<br />
Alex</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234980</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234980</link>
					<pubDate>Thu, 15 Nov 2012 18:53:01 +0000</pubDate>
					<dc:creator>Emmanuel Jourdan</dc:creator>

					<description>
						<![CDATA[
						<p>I made a quick test with iterator2 from the SDK. By throwing this in the callback function:</p>
<pre><code>if (object_classname(obj) == gensym("umenu")) {
	t_object *attr = NULL;
	object_post((t_object *)x, "umenu");

	attr = object_attr_get(obj, gensym("items"));
	if (attr) {
		long ac = 0;
		t_atom *av = NULL;
		object_attr_getvalueof(obj, gensym("items"), &#038;ac, &#038;av);
		if (ac &#038;&#038; av) {
			long i;
			post("items attribute has %d elements", ac);
			for (i = 0; i < ac; i++)
				postatom(&#038;av[i]);

			sysmem_freeptr(av);
		}
	}
}</code></code></pre><p>And it worked perfectly, so it looks like you're not getting the pointer on the object/attr.</p>
						]]>
					</description>

					
					
				</item>

			
				<item>
					<guid>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234981</guid>
					<title><![CDATA[Re: umenu &#8211; symbol value]]></title>
					<link>http://cycling74.com/forums/topic/umenu-symbol-value/#post-234981</link>
					<pubDate>Fri, 16 Nov 2012 19:39:10 +0000</pubDate>
					<dc:creator>alexyz</dc:creator>

					<description>
						<![CDATA[
						<p>Works! Ok, you were right about the pointer. Thanks a lot for helping!</p>
						]]>
					</description>

					
					
				</item>

					
		
	</channel>
	</rss>

