I have set up keyswitches and UI Buttons for different groups and they work great as most of my instruments only have a few groups to switch from. However I have a few patches that have about 20 groups and the way I have it scripted, it would be a huge task to replicate it for 20 groups. Just wondering if there is a better way at doing this for larger numbers? I am super new to scripting.
{==========================KeySwitches============================}
declare const $keyswitch1 := 0
declare const $keyswitch2 := 1
declare const $keyswitch3 := 2
set_key_color($keyswitch1, $KEY_COLOR_RED)
set_key_color($keyswitch2, $KEY_COLOR_RED)
set_key_color($keyswitch3, $KEY_COLOR_RED)
declare $current_state
{==========================Key Switch Info============================}
declare const $hx := 100
declare const $hy := 10
declare ui_label $label_T (1,1)
set_control_par(get_ui_id($label_T),$CONTROL_PAR_WIDTH,$hx)
set_control_par(get_ui_id($label_T),$CONTROL_PAR_HEIGHT,$hy)
set_control_par(get_ui_id($label_T),$CONTROL_PAR_FONT_TYPE,1)
hide_part ($label_T,$HIDE_PART_BG)
move_control_px($label_T, 51, 10)
set_text ($label_T,"Key Switch Info:")
declare ui_label $label_1 (1,1)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_WIDTH,$hx)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_HEIGHT,$hy)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,5)
hide_part ($label_1,$HIDE_PART_BG)
move_control_px($label_1, 66, 30)
set_text ($label_1,"C-2 = Ver. A")
declare ui_label $label_2 (1,1)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_WIDTH,$hx)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_HEIGHT,$hy)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,1)
hide_part ($label_2,$HIDE_PART_BG)
move_control_px($label_2, 66, 45)
set_text ($label_2,"C#-2 = Ver. B")
declare ui_label $label_3 (1,1)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_WIDTH,$hx)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_HEIGHT,$hy)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,1)
hide_part ($label_3,$HIDE_PART_BG)
move_control_px($label_3, 66, 60)
set_text ($label_3,"D-2 = Ver. C")
declare const $lab1 := $keyswitch1
declare const $lab2 := $keyswitch2
declare const $lab3 := $keyswitch3
{==========================UI Switches============================}
declare const $pw := 15
declare const $ph := 15
declare ui_switch $ks1
$ks1 := 1
set_text($ks1,"")
set_control_par_str(get_ui_id($ks1),$CONTROL_PAR_PICTURE,"onbutton")
set_control_par(get_ui_id($ks1),$CONTROL_PAR_WIDTH,$pw)
set_control_par(get_ui_id($ks1),$CONTROL_PAR_HEIGHT,$ph)
move_control_px($ks1,55,25)
declare ui_switch $ks2
set_text($ks2,"")
set_control_par_str(get_ui_id($ks2),$CONTROL_PAR_PICTURE,"onbutton")
set_control_par(get_ui_id($ks2),$CONTROL_PAR_WIDTH,$pw)
set_control_par(get_ui_id($ks2),$CONTROL_PAR_HEIGHT,$ph)
move_control_px($ks2,55,40)
declare ui_switch $ks3
set_text($ks3,"")
set_control_par_str(get_ui_id($ks3),$CONTROL_PAR_PICTURE,"onbutton")
set_control_par(get_ui_id($ks3),$CONTROL_PAR_WIDTH,$pw)
set_control_par(get_ui_id($ks3),$CONTROL_PAR_HEIGHT,$ph)
move_control_px($ks3,55,55)
{==========================UI Switches============================}
on ui_control ($ks1)
$current_state := 0
$ks1 := 1
$ks2 := 0
$ks3 := 0
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,1)
end on
on ui_control ($ks2)
$current_state := 1
$ks1 := 0
$ks2 := 1
$ks3 := 0
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,1)
end on
on ui_control ($ks3)
$current_state := 2
$ks1 := 0
$ks2 := 0
$ks3 := 1
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,1)
end on
{==========================Key Switch Info============================}
on note
disallow_group($ALL_GROUPS)
if ($current_state = 0)
allow_group(0)
end if
if($current_state = 1)
allow_group(1)
end if
if($current_state = 2)
allow_group(2)
end if
if ($EVENT_NOTE = $lab1)
$current_state := 0
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,1)
$ks1 := 1
$ks2 := 0
$ks3 := 0
end if
if ($EVENT_NOTE = $lab2)
$current_state := 1
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,1)
$ks1 := 0
$ks2 := 1
$ks3 := 0
end if
if ($EVENT_NOTE = $lab3)
$current_state := 2
set_control_par(get_ui_id($label_3),$CONTROL_PAR_FONT_TYPE,5)
set_control_par(get_ui_id($label_1),$CONTROL_PAR_FONT_TYPE,1)
set_control_par(get_ui_id($label_2),$CONTROL_PAR_FONT_TYPE,1)
$ks1 := 0
$ks2 := 0
$ks3 := 1
end if
end on