1
Lua 指令操作手冊
1. Lua 簡介 ···································································································· 2
2. Lua 程式基本語法 ························································································ 4
3. Lua 指令列表 ······························································································ 6
4. Lua 指令詳細說明 ······················································································ 14
4.1 Basic syntax (基本語法) ··········································································· 15
4.1.1 Type: bool, number, string, nil (資料型態) ··············································· 16
4.1.2 Type: table, array (矩陣運算) ······························································· 19
4.1.3 if…then…else…elseif…end, and or not (比較) ········································ 21
4.1.4 for var=1, 3 do … end (for 迴圈) ··························································· 23
4.1.5 while break, repeat until (while、repeat 迴圈) ·········································· 26
4.1.6 +-*/%^ (數學運算) ············································································· 29
4.1.7 function, call function, require return (流程控制) ······································· 30
4.1.8 logic: xor and or not lshift rshift (邏輯運算) ·············································· 32
4.2 Internal memory - $ (內部暫存器($)) ···························································· 34
4.3 Static memory - $M (斷電保持內部暫存器($M)) ············································· 40
4.4 External link (外部記憶體位址) ··································································· 46
4.5 File (文件讀取/寫入/匯出/刪除/列印) ···························································· 58
4.6 fileSlot (檔案存取) ··················································································· 71
4.7 FTP Client (FTP 傳輸功能) ········································································ 80
4.8 Math (數學運算) ····················································································· 85
4.9 Recipe (配方) ························································································· 91
4.10 Screen (螢幕控制)·················································································· 117
4.11 String (字串運算) ·················································································· 121
4.12 System library (系統參數) ······································································· 127
4.13 Serial Port communication (COM 自由通訊)················································ 131
4.14 TCP communication (TCP 自由通訊)························································· 139
4.15 UDP communication (UDP 自由通訊) ························································ 147
4.16 Text encoding (編碼格式變更) ·································································· 157
4.17 Utility (CRC 運算) ················································································· 160
4.18 Convert (浮點數轉換) ············································································· 162
4.19 Account (權限密碼設定) ········································································· 164
4.20 Mail (信件功能) ···················································································· 171
4.21 Draw (繪圖功能) ··················································································· 179