Dynamically naming colls?

jeffburger's icon

Anybody know a way to name colls dynamically? Obviously it's possible to provide a name for a coll as the argument, but I can't find a way to send a nameless coll a name on the fly. Varname doesn't seem to have anything to do with the coll name.

Thanks!

Chris Muir's icon

It's not exactly what you're asking, but do you know the refer message?

jeffburger's icon

Thanks for your response, Chris.

Yes, I'm familiar with the refer message. I don't believe it forms a complete solution for what I need, however.
Refer essentially lets me refer a secondary coll to a primary named coll. I'm trying to actually supply the name of the primary coll programatically.

The coll in question is inside a bpatcher. I want the coll to be named according to one of the arguments of the bpatcher. So let's say the bpatcher arg is "instance1". I want the coll inside this instance of the bpatcher to be named "instance1" (so that I can then refer other colls to it by the name "instance1"). I could hard code the object "coll instance1", but then it wouldn't work for other instances of that bpatcher that supply different args (for "coll instance2", "coll instance3", etc..) So I've just got a generic coll object in the bpatcher... and I want to essentially send it some sort of name message... which doesn't seem to be supported.

Then again, this could be another exciting episode of the bleeding obvious escaping me after staring at the screen too long!

Thanks!

Peter McCulloch's icon

#1 will let you provide an argument. (It's a macro: #1 get's replaced by your first argument at load time) Use #2, etc. for subsequent arguments

Also, be sure to check out #0, which generates a patch-local unique numerical identifier.

Peter McCulloch's icon

P.S. If you're using a bunch of colls, you might look into using dict.

Chris Muir's icon

Ah. What Peter says is closer to what you want then. In this case you give an argument to bpatcher that is the coll name, e.g. myCollName. Then you place the coll like [coll #1], and assuming that myCollName is argument 1 to the bpatcher, it will be instantiated as [coll myCollName].

Max is smart about showing you #1 when unlocked, and myCollName when locked, if you're viewing the bpatcher using Object—>New View in the contextual menu.

Roman Thilenius's icon

gate and forward ... as the cheapest solution. i see an abstraction called "collselect".

110.

Max Power's icon

Hey, Peter. You say "Also, be sure to check out #0, which generates a patch-local unique numerical identifier." This sounds like exactly what I need to do to solve my issue, but I'm not sure what you're referring to with #0, #1, #2 etc. Would you be able to clarify? I've looked at coll reference and help with no luck. (I'm pretty new to max as I'm sure is obvious).

mzed's icon

I just put this link on your similar question on a different, ancient thread. Here's the friendly manual: https://docs.cycling74.com/max8/vignettes/dollar_sign_and_pound_sign

Max Power's icon

Thank you for replying to both of my questions. Tremendously helpful!

Roman Thilenius's icon


(in regards to the original question from 2012 one should also add that if it would be possible to rename a coll by message, that would also include that the new name would make the coll try to read a file from disk. which would not be the best idea.)