Pushing Array Values || Its me again...
-
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.
- Isolated problem area:
for (i = 0; i < NumSliders.length; i++) { Slider2Values.push(SliderPack2.getSliderValueAt(i)); output += "\r"; } local Slider2NOW = Slider2Values.clone(); Console.print(Slider2NOW);
- 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.
Please and Thank You!
-
@Chazrox why use "\r" there?
-
@rglides im dizzy at this point. I dont know what im doing. Seems like I had it then I dont. ha.
-
@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?
-
@rglides Im sure you're right. I was just trying stuff because what I had before wasnt working for some reason.
-
@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
-
@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"; }
-
on print I get this..
Interface: NumSliders.length: undefined Interface: SliderPack2: Object 0x3705c420 Interface: [Array]
-
@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!
-
C Chazrox marked this topic as a question
-
C Chazrox has marked this topic as solved
-
C Chazrox referenced this topic