HISE Logo Forum
    • Categories
    • Register
    • Login

    Pushing Array Values || Its me again...

    Scheduled Pinned Locked Moved Solved Scripting
    9 Posts 3 Posters 81 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.
    • ChazroxC
      Chazrox
      last edited by Chazrox

      Im going crazy here....
      I've been following everyones advice on how to get the sliderpack to push to an array, then store that in an object for my preset menu. If you seen my other post, i've tried everything...

      Can somebody look at this? It is a mess but if you're the one who can fix this I know its not hard to read. Help.
      Its a mess because im going crazy trying everything lol.

      See my code please:

      This is the script for my "Save Preset" button.

      1. Isolated problem area:
      		for (i = 0; i < NumSliders.length; i++)
      		{
      			Slider2Values.push(SliderPack2.getSliderValueAt(i));
      			output += "\r";
      			
      		}
      		
      		local Slider2NOW = Slider2Values.clone();
      		
      		Console.print(Slider2NOW);
      
      1. Full button script.
      //------------------------  SAVE PRESET  ----------------------------------------------------------------------	
      	inline function onArpSaveOkControl(component, value)
      	{		
      		if (!value)
      			return;
      
      		// Declare 'Name' variable for later use. ---->
      		local ArpPresetNameNOW = ArpPresetNameToSave.get("text");
      		
      		// Overwrite Functions ---->
      		if (ArpPresetNameNOW == "") // If text field empty + click SAVE = Do this. 
      		{
      			
      			// Get Combobox index ---->
      			local selectedIndex = ArpPresetList.getValue();
      			if (selectedIndex <= 0)
      				return;
      		
      			// Use displayed preset name for 'overwrite' function ---->
      			ArpPresetNameNOW = ArpPresetList.getItemText();
      		}
      	
      		//GET COMPONENT VALUES ---->
      		local TempoNOW = knbArpSpeed.getValue();
      		local NumStepsNOW = knbNumSliders.getValue();
      		local SwingNOW = knbArpShuffle.getValue();
      		local OctaveNOW = knbOctaveRange.getValue();	
      		local TypeNOW = cmbArpType.getValue();
      		//local NotesNOW = 
      		//local LengthNOW = 
      		//local VelocityNOW = 
      		
      		//SliderPackValues
      		local NumSliders = SliderPack2.getNumSliders();
      	
      		local output = "";
      
      		
      		for (i = 0; i < NumSliders.length; i++)
      		{
      			Slider2Values.push(SliderPack2.getSliderValueAt(i));
      			output += "\r";
      			
      		}
      		
      		local Slider2NOW = Slider2Values.clone();
      		
      		Console.print(Slider2NOW);
      		
      		// SET PRESET OBJECT VALUE INDEXES HERE. 
      		ArpNotesPresets[ArpPresetNameNOW] = [
      											TempoNOW, 
      											NumStepsNOW, 
      											SwingNOW, 
      											OctaveNOW,											
      											sp2Values,
      											TypeNOW
      																																
      											];                // END OF OBJECT
      				
      		//SAVE TO FILE/OBJECT  ---->
      		presetFile.writeObject(ArpNotesPresets);
      		
      		//Update Combobox Items ---->
      		
      		// Create Array for 'Names'---->
      		local keyList = [];
      		
      		// Gather all 'keys' in object---->
      		for (k in ArpNotesPresets)
      			keyList.push(k);
      		
      		
      		// Re-populate combobox with 'keys' --->
      		// Display as current preset in combobox--->
      		ArpPresetList.set("items", keyList.join("\n"));
      		ArpPresetList.setValue(keyList.indexOf(ArpPresetNameNOW) + 1);
      		
      		// Create text input field ---->
      		ArpPresetNameToSave.set("text", "");
      	
      	};		
      	ArpSaveOk.setControlCallback(onArpSaveOkControl);
      

      ScriptWatchTable showing my arrays not showing anything saved.
      Screenshot 2025-07-13 at 2.09.03 PM.png

      Screenshot 2025-07-13 at 2.09.10 PM.png

      Please and Thank You! 🙏

      rglidesR VirtualVirginV 2 Replies Last reply Reply Quote 0
      • rglidesR
        rglides @Chazrox
        last edited by

        @Chazrox why use "\r" there?

        ChazroxC 1 Reply Last reply Reply Quote 1
        • ChazroxC
          Chazrox @rglides
          last edited by

          @rglides im dizzy at this point. I dont know what im doing. Seems like I had it then I dont. ha.

          rglidesR 1 Reply Last reply Reply Quote 0
          • rglidesR
            rglides @Chazrox
            last edited by

            @Chazrox All good, but try "\n" there, since maybe r is just wiping any values you're getting. I'm not 100% , I haven't used r before, but as far as I understand r brings the cursor to the beginning of the line rather than n which moves to the next line, right?

            ChazroxC 1 Reply Last reply Reply Quote 1
            • ChazroxC
              Chazrox @rglides
              last edited by

              @rglides Im sure you're right. I was just trying stuff because what I had before wasnt working for some reason.

              rglidesR 1 Reply Last reply Reply Quote 0
              • rglidesR
                rglides @Chazrox
                last edited by

                @Chazrox Sometimes it's best to just step away and give it fresh eyes after a few :D I've gotten myself into these holes plenty of tiems

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

                  @Chazrox said in Pushing Array Values || Its me again...:

                    for (i = 0; i < NumSliders.length; i++)
                    {
                    	Slider2Values.push(SliderPack2.getSliderValueAt(i));
                    	output += "\r";
                    	
                    }
                  

                  You need to do some Console.prints to check any variables.

                  // if the loop has no length, 
                  // no code will be executed
                  Console.print("NumSliders.length: " + NumSliders.length);
                  // make sure the component is available here
                  Console.print("SliderPack2: " + SliderPack2); 
                  
                  for (i = 0; i < NumSliders.length; i++)
                  {
                          // make sure there are values to be pushed
                          Console.print("SliderPack2 sliderValue " + i + ":" + SliderPack2.getSliderValueAt(i));
                  	Slider2Values.push(SliderPack2.getSliderValueAt(i));
                  	output += "\r"; 			
                  }
                  

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

                  ChazroxC 2 Replies Last reply Reply Quote 1
                  • ChazroxC
                    Chazrox @VirtualVirgin
                    last edited by

                    @VirtualVirgin

                    on print I get this..

                    Interface: NumSliders.length: undefined
                    Interface: SliderPack2: Object 0x3705c420
                    Interface: [Array]
                    
                    1 Reply Last reply Reply Quote 0
                    • ChazroxC
                      Chazrox @VirtualVirgin
                      last edited by Chazrox

                      @VirtualVirgin damn I been up all night on this...

                      and this was the fix...

                      WRONG

                      for (i = 0; i < NumSliders.length; i++)
                      

                      CORRECT

                      for (i = 0; i < NumSliders; i++)
                      

                      Thank You!

                      🙏

                      1 Reply Last reply Reply Quote 2
                      • ChazroxC Chazrox marked this topic as a question
                      • ChazroxC Chazrox has marked this topic as solved
                      • ChazroxC Chazrox referenced this topic
                      • First post
                        Last post

                      23

                      Online

                      1.8k

                      Users

                      12.1k

                      Topics

                      105.6k

                      Posts