Changes for page 01 Lua Functions

Last modified by Theodore Xu on 2023/10/26 10:51

From version 5.3
edited by Leo
on 2022/06/16 17:20
Change comment: Renamed from xwiki:V-BOX.V-Net.1\.User Manual.04 Lua Script.01\.Lua script function.WebHome
To version 5.5
edited by Stone Wu
on 2022/07/12 09:15
Change comment: There is no comment for this version

Summary

Details

Page properties
Title
... ... @@ -1,1 +1,1 @@
1 -01 Lua script function
1 +01 Lua Functions
Author
... ... @@ -1,1 +1,1 @@
1 -XWiki.Leo
1 +XWiki.Stone
Content
... ... @@ -1,70 +1,66 @@
1 1  = **1 Interface Description** =
2 2  
3 -== **1.1 Data type definition** ==
3 +== **Data type definition** ==
4 4  
5 -
6 6  |=**Type**|=**Description**
7 7  |=nil|Null
8 -|=boolean|Boolean, the value is true or false
9 -|=number|Integer or floating point, signed or unsigned
7 +|=boolean|Boolean (the value is true or false)
8 +|=number|Integer or floating point (signed or unsigned)
10 10  |=string|String
11 11  |=table|Table
12 12  |=function|Functions
13 13  
14 -== **1.2 Built-in function library clipping** ==
13 +== **Built-in function library clipping** ==
15 15  
16 16  Full features supported: coroutine/debug/ math/ package/ string/ table/ utf8
17 17  
18 -//,,Some features supported (available in []):** **os[clock/ date/ difftime/ time],,//
17 +//Some features supported (available in []):** **os[clock/ date/ difftime/ time]//
19 19  
20 -//,,Not supported: io/ file,,//
19 +//Not supported: io/ file//
21 21  
22 -== **1.3 Return value description** ==
21 +== **Return value description** ==
23 23  
24 24  The function return type multi means multiple return values (at least 2), usually:
25 25  
26 -//,,1st: nil;,,//
25 +//1st: nil//
27 27  
28 -//,,2nd: the error message;,,//
27 +//2nd: the error message//
29 29  
30 30  (((
31 -== **1.4 Function parameter description** ==
30 +== **Function parameter description** ==
32 32  )))
33 33  
34 -**Assume the function prototype:**
33 +Suppose a function prototype is defined:
35 35  
36 -|(((
37 -//student(string name, number age[, number class])//
35 +{{code language="LUA"}}
36 +student(string name, number age[, number class])
38 38  
39 -**Function:**
38 +Function:
40 40  
41 41  Register a student
42 42  
43 -**Parameters:**
42 +Parameters:
44 44  
45 -//name//: student name
44 +name: student name
46 46  
47 -//age//: student age
46 +age: student age
48 48  
49 -//[class=1]//: Student class
48 +[class=1]: Student class
50 50  
51 -**Return:**
50 +Return:
52 52  
53 53  Succeed: true
54 54  
55 55  Failed: multi
56 -)))
55 +{{/code}}
57 57  
58 -**Comment**
57 +**Explanation**
59 59  
60 -1.string name indicates that the first parameter name is a string
59 +1. string name indicates that the first parameter name is a string
60 +1. number age indicates that the second parameter age is numeric
61 +1. [, number class] indicates that the third parameter class is a numeric value, and it is optional. Specify the default class in class 1 in the parameter description.
62 +1. **Any parameter in the [] is considered to be an optional parameter, and may not be transmitted when called. The default value will be given in the parameter description.**
61 61  
62 -2.number age indicates that the second parameter age is numeric
63 -
64 -3. [, number class] indicates that the third parameter class is a numeric value, and it is optional. Specify the default class in class 1 in the parameter description.
65 -
66 -4. Any parameter in the brackets of [] is considered to be an optional parameter, and may not be transmitted when called. The default value will be given in the parameter description.
67 -
68 68  **Call example**
69 69  
70 70  |(((
... ... @@ -93,12 +93,11 @@
93 93  
94 94  **Comment**
95 95  
96 -1.From the print result, the second line of the first line is successfully called and returns true; the third line fails the call, the error message is translated as: the bar student has been registered, and there is indeed an error in the code.
92 +1. From the print result, the first line and the second line are successfully called and returns true; the third line fails the call, the error message is translated as: the bar student has been registered, and there is indeed an error in the code.
93 +1. The fourth line of code uses two variables to receive the return value. The call failed, the first variable stat is nil, and the second variable err stores the error message. Then print it out using print, which is the output of the third line. This example shows how to capture and view the error message.
97 97  
98 -2.The fourth line of code uses two variables to receive the return value. The call failed, the first variable stat is nil, and the second variable err stores the error message. Then print it out using print, which is the output of the third line. This example shows how to capture and view the error message.
95 +== **Modification of the Print Function** ==
99 99  
100 -== **1.5 Modification of the Print Function** ==
101 -
102 102  For the convenience of remote development, the print data is sent to the front end (web page) by means of network transmission, and the user can see the result of the debug output, because it consumes certain data and occupies the bandwidth of the server (or occupies server resources). So make the following restrictions:
103 103  
104 104  **1.Interval limit: **When debugging, transfer once every 2~~3 seconds;