Home › Forums › General › Using Ctrlr › Demo panel for MIDI receive/transmit routines › Reply To: Demo panel for MIDI receive/transmit routines
October 29, 2017 at 11:39 am
#73331
Hey Human Fly,
I finally worked out how to split a 240 byte string (e.g. direct from uiTextLabel) into 4 segments.
mySplitString = function(mod,value,source)
a=panel:getModulatorByName("stringtosplit"):getComponent():getProperty("uiLabelText")
local st = mySplitStringIntoFourSegments(a,60)
for i,v in ipairs(st) do
console(String(i.."[".. v.."]"))
panel:getComponent("string0"..i):setPropertyString("uiLabelText",v)
end
end --function
------------------------------------
function myTrim(s) -- trim leading/trailing whitespace
return (s:gsub("^%s*(.-)%s*$", "%1"))
end --function
-----------------------------------
function mySplitStringIntoFourSegments(text, stringSize)
local j=1 -- counts to 4
local s = {}
for i=1,#text,stringSize do
s[j] = myTrim(string.sub(text,i,stringSize*j))
j=j+1
end
return s
end --function
-----------------------------------
🙂
With regard to that panel I posted, did you unmute loopBe1?