1--模組與包23
--定義乙個名為 module 的模組
4module={}56
module.consta="
這是乙個常量"7
8function
module
.func1()
9io.write("
func1共有函式\n")
10end
1112
local
function
func2()
13io.write("
func2私有函式\n")
14end
1516
function
module
.func3()
17func2()
18end
1920
return
module
1--載入module.lua模組,不需要lua字尾
2require("
module")
34print(module
.consta)56
module
.func3()
7module
.func1()89
---私有函式無法列印,會報錯
10--
module.func2()
1112
--陣列 table model 列印名稱都是位址
13print(module)14
1516
17--
引入dll so
1819
--這是 linux 平台下
20--
local path = "/usr/local/lua/lib/libluasocket.so"
21--
這是 window 平台下
22--
path = "c:\\windows\\luasocket.dll"
23--
local f = assert(loadlib(path, "luaopen_socket"))
24--
f() -- 真正開啟庫
ExtJS入門之三 查詢
在web開發中,對htmldom進行查詢是必不可少的,extjs提供了高效能的查詢功能,支援css3選擇器 selector 查詢和基本的xpath查詢。extjs的查詢對xml和html均成立 看下面的html divid mydiv input type checkbox value 1 inp...
ExtJS入門之三 查詢
在web開發中,對htmldom進行查詢是必不可少的,extjs提供了高效能的查詢功能,支援css3選擇器 selector 查詢和基本的xpath查詢。extjs的查詢對xml和html均成立 看下面的html divid mydiv input type checkbox value 1 inp...
Lua的require和module小結
lua的require和module小結 module特性是lua5.1中新增的,用於設定lua檔案自己的模組,最常用的方式是module name,package.seeall 有時候lua檔名和module設定的名字不一樣,到底require的時候該 require檔名還是require模組 m...