SOLVED: Script - push command

Hi there
In the variable (onValue) i like to make an array with the command push.
It does not work? What I am doing wrong?

var harpScale = value
var scaleGroupColor = []
for (var i = 0; i < harpScale.scales.length; i++){
  scaleGroupColor = scaleGroupColor.push(harpScale.scales[i].groupColor)
setVar ("menu_2A_harp_scale","harpGroupColor",scaleGroupColor)

You once already gave me a solution, but I was a bit confused by the interpretation.

scaleGroupColor[harpScale.scales[i].groupColor] = i

I have records from 0 to 71 and this was the result.
Bildschirmfoto 2023-04-24 um 13.30.38
Until I realized that the same content are combined.
I'll try the if query...

Hi Denis,

There are two things I'm noticing wrong in the code you listed.

  1. You're overwritting scaleGroupColor in the loop instead of just pushing to the outside array.
  2. There is a space inbeteween setVar ( which can't be there.

Here is the corrected code. I hope this helps. =)

var harpScale = value;
var scaleGroupColor = [];
for (var i = 0; i < harpScale.scales.length; i++) {


Thanks... i will give a try...

Unbelievable... it runs flawlessly... thank you very much.

PS: I need to check again all my setVar if no spacing may be. Is this only here?

Spaces before parenthesis are legal (but unpopular).

1 Like

That's good to know. Every day I learn something new... Thanks

1 Like

I actually had zero clue it was legal, thank you for pointing that out. =)