Having a hard time with panel.setValue() syntax
-
I have some panel data that was being set like this in a loop:
rack.data["row" + i] = panel;
and
rack.data.rows[i] = panel;
and instead I am trying to save this in the panel's value
I am using:
rack.setValue( { ["row" + i]: panel, "rows"[i]: panel });
but I am just getting errors from this such as:
'''
Found '[' when expecting identifier
'''I've been fiddling around with the syntax to try to get it work, but I just can't seem to get it.
-
@VirtualVirgin You can't use an array as a key.
-
@d-healey
I've tried this:rack.setValue ({ "row" + i: panel, });
but it says:
Found '+' when expecting ':'
-
@VirtualVirgin Try putting it in
()
-
@d-healey
I'm not sure which "it" you meant, so I tried all combinations:"row" (+) i: panel "row" + (i): panel ("row") + i: panel ("row" + i): panel ("row" + i: panel) "row" + i: (panel) "row" + i(:) panel
All of those throw an error
-
Yeah it looks like it doesn't work in HISE script. You'll need to create the key separately, like this
const i = 10; const key = "row" + i; const myObj = {key: "Hello"}; Console.print(trace(myObj));
-
@d-healey Thank you!