0 Members and 3 Guests are viewing this topic.
I'm actually not too sure that its your fault, as usually, the program doesn't crash the calulator, it just tells you about the syntax error.
It's probably a meta method, and is probably not ment to be used in normal scripts
function on.deleteKey() msg = string.char() --also used msg = ""end
msg = ""function on.paint(gc) gc:drawString(msg, 10, 10, "top")endfunction on.char(ch) msg = ch platform.window:invalidate()end
While doing some ... exploring, I found a __gc() function in the 'val' table, and called that with the table as an arguments, and then my calculator crashed
msg = ""function on.paint(gc) gc:drawString(msg, 10, 10, "top")endfunction on.char(ch) msg = ch platform.window:invalidate()endfunction on.enterKey() msg = "" platform.window:invalidate()end
function on.backspaceKey() if self.var:len() > 0 then self.var = string.sub(self.var, 1, self.var:len()-1) end platform.window:invalidate()endfunction on.clearKey() self.var = "" platform.window:invalidate()end
function on.backspaceKey() if string.len(msg) > 0 then msg = string.sub(msg, 1, string.len(msg)-1) end platform.window:invalidate() end function on.clearKey() msg = "" platform.window:invalidate() end
Thanks Levak. I changed it toCode: [Select]function on.backspaceKey() if string.len(msg) > 0 then msg = string.sub(msg, 1, string.len(msg)-1) end platform.window:invalidate() end function on.clearKey() msg = "" platform.window:invalidate() endAnd it works perfectly.
function duplicate(obj) if type(obj) ~= "table" then return obj else local t = {} for key,value in pairs(obj) do t[key] = duplicate(value) end return t endend