HISE Logo Forum
    • Categories
    • Register
    • Login

    Having trouble with syntax for settings a panel value

    Scheduled Pinned Locked Moved Scripting
    5 Posts 3 Posters 99 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      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.

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

      ustkU 1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by

        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 });
        

        Dan Korneff - Producer / Mixer / Audio Nerd

        VirtualVirginV 1 Reply Last reply Reply Quote 0
        • ustkU
          ustk @VirtualVirgin
          last edited by

          @VirtualVirgin

          chordPadsPSArrays[i][j] = [];
          

          This is a 3d array since your store an array into an already 2D array

          Can't help pressing F5 in the forum...

          VirtualVirginV 1 Reply Last reply Reply Quote 0
          • VirtualVirginV
            VirtualVirgin @Dan Korneff
            last edited by

            @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];
            

            You can listen to my orchestral mockups here:
            https://www.virtualvirgin.net/

            1 Reply Last reply Reply Quote 0
            • VirtualVirginV
              VirtualVirgin @ustk
              last edited by

              @ustk said in Having trouble with syntax for settings a panel value:

              @VirtualVirgin

              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).

              You can listen to my orchestral mockups here:
              https://www.virtualvirgin.net/

              1 Reply Last reply Reply Quote 1
              • First post
                Last post

              6

              Online

              1.8k

              Users

              12.1k

              Topics

              104.9k

              Posts