Forums > MaxMSP

dict get

January 10, 2012 | 4:13 pm

Despite what it says in the help, when you send ‘get mykey’ to [dict mydict] you get the key and the value out of the second output (not just the value). Usually I don’t want to know the key so I have to loose it somehow, usually by using [route mykey].

I feel like there should be a better way to do this, is there?


January 10, 2012 | 4:30 pm

That’s perfectly acceptable. You can also do "unpack s i" and get the second outlet. That would allow to have different keys and not worry about route.


January 10, 2012 | 6:09 pm

True, but I still have to think about if I need [unpack s i], [unpack s f] etc.

taking the right output from [zl.slice 1] is the best I have come up with so far.

Shame you can’t pass the name of the dict an an argument to [dict] could easily make an abstraction then.

It is a silly small point but being able to do something like [dictutil mydict get mykey] and jut get the value would be ideal, 1 object not 3 much less visual noise in the patch.

The fact that dicts now exist at all is really great, so I will stop moaning and keep patching.


January 10, 2012 | 7:32 pm

I usually put a message object with $2 or $2 $3 if the key contains another dict ;]


January 10, 2012 | 11:47 pm

I’m using the following a fair bit as an abstraction:

– Pasted Max Patch, click to expand. –

same result as zl slice but might be handy to be able to route some other keys while you’re at it.


Viewing 5 posts - 1 through 5 (of 5 total)