首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > 编程 >

QuickLuaTour通译流水账(31-38)

2012-08-31 
QuickLuaTour翻译流水账(31-38)-- Example 31--[[Standard LibrariesLua has standard built-in libraries

QuickLuaTour翻译流水账(31-38)

-- Example 31   --[[  Standard Libraries  Lua has standard built-in libraries for common operations in  math, string, table, input/output & operating system facilities.  External Libraries  Numerous other libraries have been created: sockets, XML, profiling,  logging, unittests, GUI toolkits, web frameworks, and many more.]]------- Output ---------- 例子 31   --[[  标准库  Lua 有许多用于通用操作的标准的内建库,比如数学  字符串,表,输入/输出和操作系统的工具  外部库  现有的其它的库有N多:sockets, XML, 性能分析,  日志,单元测试,图形界面工具,web框架等等]]-- Example 32  -- Standard Libraries - math.-- Math functions:-- math.abs, math.cos, math.asin, math.atan, math.atan2,-- math,ceil, math.cos, math.cosh, math.deg, math.exp, math.floor,-- math.fmod, math.frexp, math,huge, math.ldexp, math.log, math.log10-- math.max, math.min, math.modf, math.pi, math.pow, math.rad,-- math.random, math.randomseed, math.sin, math.sinh, math.sqrt,-- math.tan, math.tanhprint(math,sqrt(9), math.pi)------ Output ------3          3.1415926535898-- Example 33  -- Standard Libraries - string.-- String functions:-- string.byte, string.char, string.dump, string.find, string.format,-- string.gfind, string.gsub, string.len, string.lower, string.match,-- string.rep, string.reverse, string.sub, string.upperprint(string.upper("lower"), string.rep("a", 5), string.find("abcde", "cd"))------ Output ------LOWER aaaaa  3         4-- Example 34  -- Standard Libraries - table.--Table functions:-- table.concat, table.insert, table.maxn, table.remove, table.sorta={2}table.insert(a,3);table.insert(a,4);table.sort(a,function(v1,v2) return v1 > v2 end)for i,v in ipairs(a) do print(i,v) end------ Output ------1      42      33      2-- Example 35  -- Standard Libraries - input/output.-- IO functions:-- io.close, io.flush, io.input, io.lines, io.open, io.output, io.popen,-- io.read, io.stderr, io.stdin, io.stdout, io.tmpfile, io.type, io.write,-- file:close, file:flush, file:lines, file:read,-- file:seek, file:setvbuf, file:writeprint(io.open("file doesn't exist", "r"))------ Output ------nil     file doesn't exist: No such file or derectory   2-- Example 36  -- Standard Libraries - operating system facilities.-- OS functions:-- os.clock, os.date, os.difftime, os.execute, os.exit, os.getenv,-- os.remove, os.rename, os.setlocale, os.time, os.tmpnameprint(os.date())------ Output ------06/20/12 11:48:30-- Example 37  -- External Libraries-- Lua has support for external modules using the 'require' function-- INFO:A dialog will popup but it could get hidden behind the console.require("iuplua")ml = iup.multiline    {        expand="YES",        value="Quit this multiline edit app to continue Tutorial!",        border="YES"    }dlg = iup.dialog{ml; title="IupMultiline", size="QUARTERxQUARTER",}dlg:show()print("Exit GUI app to continue!")iup.MainLoop()------ Output --------Exit GUI app to continue!-- Example 38   --[[  to learn more about Lua scripting see  Lua Tutorials: http://lua-users.org/wiki/TutorialDirectory  "Programing in Lua" Book: http://www.inf.puc-rio.br/~reberto/pil2/  Lua 5.1 Reference Manual:      Start/Programs/Lua/Documentation/Lua 5.1 Reference Manual  Examples Start/Programs/Lua/Examples]]------ Output -------]]
?

热点排行