Lua中的loadfile、dofile、loadstring、require用法实例
do
localerrorInfo=loadfile("test.lua");--loadcodefile
if(errorInfo==nil)then
print("loadfilefailed");
else
print("loadfilesuccess");
localdoInfo=dofile("test.lua")--compliethefileandexecutethefile
if(doInfo==0)then
print("runfilefailed");
else
print("runfilescuess");
end
end
--locali=0;--itmustbeglobalvar,theloadstringonlycalltheglobalvar i=0; localf=loadstring("i=i+1");
f(); print(i); g=function() i=i+1;--itcancallthelocalandtheglobalvar end g(); print(i); end
热门推荐
10 八一幼儿祝福语大全简短
11 公司乔迁食堂祝福语简短
12 婚礼结束聚餐祝福语简短
13 儿媳买车妈妈祝福语简短
14 毕业送礼老师祝福语简短
15 同事辞职正常祝福语简短
16 恭贺新婚文案祝福语简短
17 金店立秋祝福语简短英文
18 婆婆高寿祝福语大全简短