Addressing local variables in Js

Lucas Hui's icon

Hi

I'm working on a Max for Live device and to stop multiple instances of the device communicating with each other, I have localised all of the variables, Dicts and Colls (using --- before name).

I'm using some JS inside the device to access information stored in 2 Dicts, however when the Dicts are made local only (named Dict ---NAME), I'm struggling to find a way to access them (since the --- are changed to a unique number ID, doing "new Dict("---NAME"); doesn't work).

Does anyone know how to access them? Or a way to find out the numbers that --- are changed to?

Thanks

achzo's icon

send a message ---name to js function, then use name property to change dict name you're accessing

Lucas Hui's icon

Hi ACHZO thanks for replying so fast.

Please could you elaborate on your solution? I don't think I understand.

The --- is a randomly generated number that changes every time the patch is loaded. Plus renaming the Dict deletes the contents (I think), which needs to be saved with the Ableton set.

I'm contemplating creating a script that runs the first time to give every instance a unique identifier, but there must be a better way?

achzo's icon

if you work in m4l, set your unique ---dict parameter mode enable, so it will be saved as a blob with the live set. in js you refer to a named dict, you don't actually change it's name. in max, message ---name will have unique name (as your ---dict). so sending this unique name to refer to your unique dict is what you need.