[dict] Can you create a hierarchy of keys using "set" message?

Chris Vik's icon

I'm trying to turn incoming lists into hierarchies of dictionary keys dynamically, where the final symbol of the list is the value.

Example:

Incoming message"all of the things"

Dictionary "get all::of::the" result"all::of::the things"

Ideally, I would like to use a simple "set" message to create the keys and value for each entry as they are entered into the dictionary, but it doesn't seem like [dict] works that way.

Example of what I want to do"set all::of::the things

It's quite unfortunate, but the Max help file only shows how to "get" entries under the hierarchy tab, with no information on how to "set". In fact, there is no information on how to create a dictionary with cascading keys at all.

Max Patch
Copy patch and select New From Clipboard in Max.

This is what I'm trying to do:

Are there any alternative solutions?

Mathieu Chamagne's icon

use "replace" instead of "set", and it will create keys hierarchy.

Chris Vik's icon

Thanks Mathieu.

That works well. I haven't adjust my patch to work in this way just yet, but it should work well for my purposes.

I'm interested as to where you saw that "replace" is a usable message for dict. I couldn't find it in any of the documentation.

Cheers.

Mathieu Chamagne's icon

well... it is in dict references :replace    key [symbol]
value [list]
Set the value for a key to a specified value. If a heirarchy is specified for the key, and the heirarchy does not exist, then it will be created in the dictionary.

but I agree with you : dict maxhelp & doc is a bit... slim !
a couple of example patches would be very welcome to help understand all the powerful features of this great object !

Chris Vik's icon

Well aren't I a dumb dumb. I always check out the help files thoroughly, but I never click on the "Show More" text link to expand the messages references. I couldn't imagine why they decide to hide some by default when there's an arrow on the left to hide the items anyway

Suppose it's another habit I'll have to change. Cheers again!

theiamania's icon

Unforgivable...

9 years later I had to find this thread to be able to do this very thing. The help file makes no mention of how to do it.

Thank you Mathieu