Home › Forums › General › Using Ctrlr › Demo panel for MIDI receive/transmit routines › Reply To: Demo panel for MIDI receive/transmit routines
myMethod = function(--[[ CtrlrModulator --]] mod, --[[ number --]] value, --[[ number --]] source)
extBank = L(panel:getModulatorByName("lcd_bankDataB"):getComponent():getProperty("uiLabelText"))
console("Retrieving external bank : "..extBank)
--make a memory block from the string
memB = MemoryBlock(extBank) -- this variable is used to send midi????
--check size of received dump
local size = memB:getSize() -- same as size=string.len(extBank)???
console("midiMessageReceived: " .. size .. "bytes")
if size == 80 then --bank dump
console("bank dump detected!")
end
extBank:gsub("(%w+)",function(c) table.insert(tabl_extBank,c) end)
for i,v in ipairs(tabl_extBank) do
console("i="..i.." v="..v)
end
console("size of tabl_extBank="..#tabl_extBank)
end
–convert bank to table tabl_extBank = {} for i=1,80 do s=extBank:toHexString(1) table.insert(tabl_extBank,s) end
I think toHexString(1) just dumps a memory block into a string. ‘extBank’ is a string obtained from a uiTextLabel, so it is not a memory block. To convert a string into a table, you would need to split or explode it somehow using a delimiter (like excel does with csv files). The code above gsub(“(%w+)” does a similar thing by ignoring whitespace and just loading the number 0-9 or letter A-F into each element of the table. Not fully tested though 🙂
extBank:gsub("(%w+)",function(c) table.insert(tabl_extBank,c) end)
I found it here.