Having trouble with syntax for settings a panel value
-
I have a 2D array initialized in a panel's value like this:
// initialize pitch set arrays local chordPadsPSArrays = []; chordPadsPSArrays.reserve(rows); for (i = 0; i < rows; i++) { chordPadsPSArrays[i] = []; chordPadsPSArrays[i].reserve(columns); for (j = 0; j < columns; j++) { chordPadsPSArrays[i][j] = []; } } panel.setValue ({ "pitchSetArrays" : chordPadsPSArrays });
Later I am trying to write to the value with
panel.setValue({"pitchSetArrays"[0][0] : [this.data.keyNumber]});
But I am getting
Found '[' when expecting ':'
So I am not sure how to write this to save to the index of the 2D array that I need.
-
In your code, the key is written as "pitchSetArrays"[0][0], which is trying to index the string "pitchSetArrays".
I think you need to do something like :
pitchSetArrays[0][0] = this.data.keyNumber; panel.setValue({ "pitchSetArrays": pitchSetArrays });
-
chordPadsPSArrays[i][j] = [];
This is a 3d array since your store an array into an already 2D array
-
@Dan-Korneff said in Having trouble with syntax for settings a panel value:
In your code, the key is written as "pitchSetArrays"[0][0], which is trying to index the string "pitchSetArrays".
I think you need to do something like :
pitchSetArrays[0][0] = this.data.keyNumber; panel.setValue({ "pitchSetArrays": pitchSetArrays });
So I tried a few methods like this but couldn't get it to work.
Confusingly, I found the method to set the value at the specified array index by using the .getValue() method as so:
panel.getValue().pitchSetArrays[0][0] = [this.data.keyNumber];
-
@ustk said in Having trouble with syntax for settings a panel value:
chordPadsPSArrays[i][j] = [];
This is a 3d array since your store an array into an already 2D array
Sure, at that point the 2D array becomes a 3D array. I'm jest referring to it that way as the address is 2D (rows, columns in this example).