Published in: Lua
Example of: split, for, string concatenation, function call, etc
function split (s,t) local l = {n=0} local f = function (s) l.n = l.n + 1 l[l.n] = s end local p = "%s*(.-)%s*"..t.."%s*" s = string.gsub(s,"^%s+","") s = string.gsub(s,"%s+$","") s = string.gsub(s,p,f) l.n = l.n + 1 l[l.n] = string.gsub(s,"(%s%s*)$","") return l end
Comments
Subscribe to comments
You need to login to post a comment.

-- (based on piece of code used for the QT wrapper library) local digits = split("a b c d e f g h i j k l", " ") for i=1,6 do b = self.panel:getButtonBridge("screen.button"..digits[i]) self:connect(b, b.pressed, self, self.buttonpressed,i) end