Code: Select all
------------------------------
-- SWITCH (SELECT CASE like)
------------------------------
-- sample 1
local a = 2
local switch = {
[1] = function()print "Case 1."end,
[2] = function()print "Case 2."end,
[3] = function()print "Case 3."end
}
local f = switch[a]
if(f) then
f()
else
print "Case default."
end
-- other sample for the function array only
local chann_on = {
["A"] = function() txt_style(str_channelA,txt_style5) end,
["B"] = function() txt_style(str_channelB,txt_style5) end,
["C"] = function() txt_style(str_channelC,txt_style5) end,
["D"] = function() txt_style(str_channelD,txt_style5) end,
["E"] = function() txt_style(str_channelE,txt_style5) end,
["F"] = function() txt_style(str_channelF,txt_style5) end,
["G"] = function() txt_style(str_channelG,txt_style5) end,
["H"] = function() txt_style(str_channelH,txt_style5) end,
["I"] = function() txt_style(str_channelI,txt_style5) end,
["J"] = function() txt_style(str_channelJ,txt_style5) end,
["K"] = function() txt_style(str_channelK,txt_style5) end,
["L"] = function() txt_style(str_channelL,txt_style5) end,
["M"] = function() txt_style(str_channelM,txt_style5) end,
["N"] = function() txt_style(str_channelN,txt_style5) end,
["O"] = function() txt_style(str_channelO,txt_style5) end,
["P"] = function() txt_style(str_channelP,txt_style5) end
}
-- sample 3
local btn_pr = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() end,
[6] = function() end,
[7] = function() end,
[8] = function() end,
[9] = function() end,
[10] = function() end,
[11] = function() end,
[12] = function() end,
[13] = function() end,
[14] = function() end,
[15] = function() end,
[16] = function() end
}
function pr_arr_press_capt(row, col)
-- print("CAPT button pressed at row " .. row .. ", col " .. col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
print("CAPT PRESS Multiply : "..(col+1)+(row*4))
end
-- sample 4
local btn_pr2 = {
[1] = function() press_EXEC() end,
[2] = function() press_INIT() end,
[3] = function() press_RTE() end,
[4] = function() press_CLB() end,
[5] = function() press_MENU() end,
[6] = function() press_LEGS() end,
[7] = function() press_DEPARR() end,
[8] = function() press_N1() end,
[9] = function() press_FIX() end,
[10] = function() press_PREV() end,
[11] = function() press_NEXT() end,
[12] = function() press_ONE() end,
[13] = function() press_TWO() end,
[14] = function() press_THREE() end,
[15] = function() press_FOUR() end,
[16] = function() press_FIVE() end
}
local btn_rl2 = {
[1] = function() end,
[2] = function() end,
[3] = function() end,
[4] = function() end,
[5] = function() release_MENU() end,
[6] = function() end,
[7] = function() end,
[8] = function() end,
[9] = function() end,
[10] = function() end,
[11] = function() end,
[12] = function() end,
[13] = function() end,
[14] = function() end,
[15] = function() end,
[16] = function() end
}
function pr_arr2_press(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_pr2[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end
function pr_arr2_release(row, col)
btn_nbr = (col+1)+(row*4)
local f_exec_btn_pr = btn_rl2[btn_nbr]
if (f_exec_btn_pr) then
f_exec_btn_pr()
else
end
end