Good places for variables when using matrix

Hi

I use the "ultimate custom module" for Cubase in order to dynamically get articulations names.

The matrix i use to get those articulations is set this way in the CM :

ConstruisTaMap().then(cequilmefaut => {
      
        receive('/EDIT', 'matrix_articulations', {'props': `JS{
                var props={}
                let Index=parseInt($)+1
                props.id="b"+Index
         ...
                var labs = ${JSON.stringify(mesArticulations)} 
                var max = labs.length
                props.label= labs[$]
                props.visible = Index <= max                                                   

                props.onCreate = max <= 4 ? "setVar('parent','GT',1)" : "setVar('parent','GT',2)"

                props.address="/note"
                props.preArgs=[1,$]
                props.target="midi:KSCC"
                return props
                }`})

So, the props.onCreate line is used to change the matrix gridTemplate property, using VAR{GT}.
It works :
grid

But, i have this in the console :

Uncaught TypeError: Cannot read properties of undefined (reading 'container')
at ownKeys (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2576:4231)
at strict";require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.string.trim.js"),require (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2564:19303)
at incrementWidget (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2369:655)
at EDIT (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2441:722)
at EDIT (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2441:3628)
at strict";require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.array.iterator.js"),require (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2435:939)
at bundle (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2405:610)
at localUuid (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2408:1045)
at customEvents={};setTimeout(()=>{customEvents.draginit=customEvents.drag=customEvents.dragend=require("./drag"),customEvents.resize=require("./resize"),customEvents.wheel=require("./dom-event")("wheel"),customEvents.scroll=require("./dom-event")("scroll",{capture:!0}),customEvents.click=require("./dom-event")("click"),customEvents["fast-click"]=require("./dom-event")("fast-click"),customEvents.focus=require("./dom-event")("focus",{capture:!0}),customEvents.blur=require("./dom-event")("blur",{capture:!0}),customEvents.change=require("./dom-event") (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2390:863)
at localUuid (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2408:2360)
Uncaught TypeError: Cannot read properties of undefined (reading 'container')
at ownKeys (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2576:4231)
at strict";require("core-js/modules/es.array.iterator.js"),require("core-js/modules/web.dom-collections.iterator.js"),require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.string.replace.js"),require("core-js/modules/es.string.trim.js"),require (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2564:19303)
at incrementWidget (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2369:655)
at EDIT (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2441:722)
at EDIT (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2441:3628)
at strict";require("core-js/modules/es.regexp.exec.js"),require("core-js/modules/es.array.iterator.js"),require (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2435:939)
at bundle (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2405:610)
at localUuid (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2408:1045)
at customEvents={};setTimeout(()=>{customEvents.draginit=customEvents.drag=customEvents.dragend=require("./drag"),customEvents.resize=require("./resize"),customEvents.wheel=require("./dom-event")("wheel"),customEvents.scroll=require("./dom-event")("scroll",{capture:!0}),customEvents.click=require("./dom-event")("click"),customEvents["fast-click"]=require("./dom-event")("fast-click"),customEvents.focus=require("./dom-event")("focus",{capture:!0}),customEvents.blur=require("./dom-event")("blur",{capture:!0}),customEvents.change=require("./dom-event") (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2390:863)
at localUuid (http://192.168.0.11:8080/client/open-stage-control-client.js?version=1.14.6:2408:2360)

So... is the way i set the matrix gridTemplate ok ? I may be still confused on how it works, but if i'm right, here props.onCreate will set the GT variable 50 times if i do have 50 buttons... so... is there a better place / way to set the whole thing ?

Thank you

It doesn't really make sense to set gridTemplate this way, you could simply modify it with the /EDIT command:

var GT = 2 // compute grid template here
receive('/EDIT', 'id', {props: 'JS{...}', gridTemplate: GT}

As for the error, you fell in one of the advanced syntaxes limitations:

  • container widgets can inherit their children's properties only to define dynamic properties

The documentation however doesn't make it very clear that it applies not only to the @{} syntax.

Ok, thank you.

As GT depends on other variables, I finally found that i had to set GT up in the async function definition to get the whole thing working. That's what i was looking for :slight_smile: