CONTROL ID NOt DECLARED

Hi,
I'm trying to make an interface with 2 windows. In this case option_1 and option_2. The goal is when I select option_1, option_2 disappears and vice versa. As long as I have the same number of elements in the arrays for each window it works fine. The problem starts when i add an element to one of the arrays. Everything works fine but when I click on option_2 it says control id was not declared. I can't understand what I'm doing wrong.
At this point "polypx" on vi-control told me that the while loops are assuming they are the same size. How can i make them assume the real size of each array? Is it possible?
on init set_ui_height(30) make_perfview message("") declare %option_1[5] declare %option_2[6] declare $i {-----------Option 1-----------} declare ui_switch $swi_option1 move_control($swi_option1,5,1) declare ui_switch $swi_option2 move_control($swi_option2,6,1) declare ui_switch $swi_test1 move_control($swi_test1,1,1) declare ui_switch $swi_test2 move_control($swi_test2,1,2) declare ui_switch $swi_test3 move_control($swi_test3,1,3) declare ui_switch $swi_test4 move_control($swi_test4,1,4) declare ui_switch $swi_test5 move_control($swi_test5,1,5) %option_1[0] := get_ui_id($swi_test1) %option_1[1] := get_ui_id($swi_test2) %option_1[2] := get_ui_id($swi_test3) %option_1[3] := get_ui_id($swi_test4) %option_1[4] := get_ui_id($swi_test5) {-----------Option 2-----------} declare ui_switch $swi_test6 move_control($swi_test6,2,1) declare ui_switch $swi_test7 move_control($swi_test7,2,2) declare ui_switch $swi_test8 move_control($swi_test8,2,3) declare ui_switch $swi_test9 move_control($swi_test9,2,4) declare ui_switch $swi_test10 move_control($swi_test10,2,5) declare ui_switch $swi_test11 move_control($swi_test11,2,6) %option_2[0] := get_ui_id($swi_test6) %option_2[1] := get_ui_id($swi_test7) %option_2[2] := get_ui_id($swi_test8) %option_2[3] := get_ui_id($swi_test9) %option_2[4] := get_ui_id($swi_test10) %option_2[5] := get_ui_id($swi_test11) end on function show_option_1 $i := 0 while ($i<num_elements(%option_1)) set_control_par(%option_2[$i],$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL) set_control_par(%option_1[$i],$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING) $swi_option2 := 0 inc($i) end while end function function show_option_2 $i := 0 while ($i<num_elements(%option_2)) set_control_par(%option_1[$i],$CONTROL_PAR_HIDE,$HIDE_WHOLE_CONTROL) set_control_par(%option_2[$i],$CONTROL_PAR_HIDE,$HIDE_PART_NOTHING) $swi_option1 := 0 inc($i) end while end function on ui_control($swi_option1) call show_option_1 end on on ui_control($swi_option2) call show_option_2 end on
Best Answer
-
In the second function you´re looping for 6 elements through an array with 5 indexes. (num_e of option2 = 6, so in the last loop iteration you´ll get option_1[5] -> and whoops there it happens, index not declared)
Put it into two seperate while loops(in each function), one going till num_elements of option1, the other of option2, then only hide the 1 or 2 stuff in their own while loop.
1
Answers
-
In the second function you´re looping for 6 elements through an array with 5 indexes. (num_e of option2 = 6, so in the last loop iteration you´ll get option_1[5] -> and whoops there it happens, index not declared)
Put it into two seperate while loops(in each function), one going till num_elements of option1, the other of option2, then only hide the 1 or 2 stuff in their own while loop.
1 -
Hi,
That's it! Thank you, but I actually give a try to "ui_panels" and it's a lot more easy to do this way.
Thank you!
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 63 NI News
- 792 Tech Talks
- 4.1K Native Access
- 16.7K Komplete
- 2K Komplete General
- 4.4K Komplete Kontrol
- 5.8K Kontakt
- 1.6K Reaktor
- 384 Battery 4
- 852 Guitar Rig & FX
- 430 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.4K Traktor
- 7.4K Traktor Software & Hardware
- Check out everything you can do
- Create an account
- See member benefits
- Answer questions
- Ask the community
- See product news
- Connect with creators