Shorten Commands

Does anyone know how to write this in a simpler way?
set_control_par_str(get_ui_id($switch_1),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_2),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_3),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_4),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_5),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_6),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_7),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_8),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_9),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_10),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_11),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_12),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_13),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_14),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_15),$CONTROL_PAR_PICTURE,"switch")
set_control_par_str(get_ui_id($switch_16),$CONTROL_PAR_PICTURE,"switch")
Best Answers
-
what @corbo-billy is talking about is:
all ui controls in kontakt have an ID, hence why you use the get_ui_id function to grab each of these controls' ID before setting the control par str.
What you could do instead of a macro, using regular vanilla KSP is:
declare $loop_count := 0 declare %switch_ids[16] %switch_ids[0] := get_ui_id($switch_1) %switch_ids[1] := get_ui_id($switch_2) %switch_ids[2] := get_ui_id($switch_3) { ... and so on up to 16 } { then at the moment you need to set those control parameters you do: } $loop_count := 0 while ($loop_count < 16) set_control_par_str(%switch_ids[$loop_count],$CONTROL_PAR_PICTURE,"switch") inc($loop_count) end while
A little less elegant than the macro version, but more efficient and vanilla code, no need to use Sublime or KSP plugin.
1 -
Thank you very much friend, you were a great help, greetings.
0
Answers
-
yes, if you use Sublime KSP (Sublime Text, the code editor + KSP plugin) you can write:
iterate_macro(set_control_par_str(get_ui_id($switch_#n#), CONTROL_PAR_PICTURE,"switch") := 1 to 16
the plugin has the functionality to compile what we could call SublimeKSP code (above) into regular (vanilla) KSP. In the end it is the same result, but the code you look at everyday while developing your instrument is way simpler and shorter.
0 -
Is there a way to write that code without having to write the same thing many times?
0 -
Directly, from the KSP editor, you must gather all the switches in an Array and apply the execution, the attribution of this image to each switch by the process of a "while loop" with the keywords while __ end while .
Sorry but I'm not very pedagogical and my English is limited.
1 -
can you give me an example??? Sorry but I know very little about the code
0 -
what @corbo-billy is talking about is:
all ui controls in kontakt have an ID, hence why you use the get_ui_id function to grab each of these controls' ID before setting the control par str.
What you could do instead of a macro, using regular vanilla KSP is:
declare $loop_count := 0 declare %switch_ids[16] %switch_ids[0] := get_ui_id($switch_1) %switch_ids[1] := get_ui_id($switch_2) %switch_ids[2] := get_ui_id($switch_3) { ... and so on up to 16 } { then at the moment you need to set those control parameters you do: } $loop_count := 0 while ($loop_count < 16) set_control_par_str(%switch_ids[$loop_count],$CONTROL_PAR_PICTURE,"switch") inc($loop_count) end while
A little less elegant than the macro version, but more efficient and vanilla code, no need to use Sublime or KSP plugin.
1 -
Thank you very much friend, you were a great help, greetings.
0
Categories
- All Categories
- 19 Welcome
- 1.5K Hangout
- 62 NI News
- 786 Tech Talks
- 4.1K Native Access
- 16.6K Komplete
- 2K Komplete General
- 4.3K Komplete Kontrol
- 5.7K Kontakt
- 1.6K Reaktor
- 380 Battery 4
- 847 Guitar Rig & FX
- 429 Massive X & Synths
- 1.3K Other Software & Hardware
- 5.8K Maschine
- 7.3K Traktor
- 7.3K 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