Code: Select all
expression = "5+6-2"
script = "return " .. expression -- convert to LUA script
func, err = loadstring(script)
if err then
-- syntax error
else
result = func() -- now result == 9
end
will work.
Code: Select all
expression = "5+6-2"
script = "return " .. expression -- convert to LUA script
func, err = loadstring(script)
if err then
-- syntax error
else
result = func() -- now result == 9
end