Saving and recalling presets with Javascript and dict in M4L device

Uasmi Nasser's icon

Hi,

I'm trying to implement a saving and recalling presets functionality using dict and js. To access an object within a subpatcher with a unique name ("---object", for example), I am using this code:

return this.patcher.getnamed("---main").subpatcher().getnamed("---object").getvalueof();

This works fine until I try to use it after freezing the patcher, where I start to get error messages saying that the object is null. I assume this is related to unique names being assigned with additional characters after freezing? Or am I missing something?

Just to reference the structure of the patch - both dict and js code are located and called in the main patcher, and the objects (with unique names) I'm trying to access are located in the subpatcher (with a unique name as well).

TFL's icon

If I remember correctly #0 and --- don't get parsed in js as they are in the context of the max patch.
But you can work around this by passing your ---name values as arguments of your js/v8 object, like so: [v8 code.js ---main ---object] and then you can access the correctly parsed ---main and ---object using jsarguments[1] and jsarguments[2].