do
local errorInfo = loadfile("test.lua"); --load code file
if(errorInfo == nil) then
print("load file failed");
else
print("load file success");
local doInfo = dofile("test.lua") --complie the file and execute the file
if(doInfo == 0) then
print("run file failed");
else
print("run file scuess");
end
end
--local i = 0;--it must be global var, the loadstring only call the global var
i = 0;
local f = loadstring("i = i + 1");
f();
print(i);
g = function()
i = i + 1; --it can call the local and the global var
end
g();
print(i);
end