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
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
Summary
-
Page properties (3 modified, 0 added, 0 removed)
Details
- Page properties
-
- Title
-
... ... @@ -1,1 +1,1 @@ 1 -01 Lua script function1 +01 Lua Functions - Author
-
... ... @@ -1,1 +1,1 @@ 1 -XWiki. Leo1 +XWiki.Stone - Content
-
... ... @@ -1,70 +1,66 @@ 1 1 = **1 Interface Description** = 2 2 3 -== ** 1.1Data 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 false9 -|=number|Integer or floating point ,signed or unsigned7 +|=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.2Built-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.3Return 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.4Function parameter description** ==30 +== **Function parameter description** == 32 32 ))) 33 33 34 - **Assumethefunction 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 name44 +name: student name 46 46 47 - //age//: student age46 +age: student age 48 48 49 - //[class=1]//: Student class48 +[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,20 +93,17 @@ 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.Thefourth line ofcode uses two variables to receive the return value. The call failed,the first variable stat is nil, and the secondvariable err storestheerror message. Then printit out using print, which isthe output of the third line. This example shows how to capture andview the error message.95 +== **Modification of the Print Function** == 99 99 100 - ==**1.5Modification of thePrintFunction**==97 +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 the following restrictions are made. 101 101 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: 99 +1. **Interval limit: **When debugging, transfer once every 2~~3 seconds; 100 +1. **Data limit: **The transfer data cannot be larger than 1.5KB in a single transmission, otherwise the extra part will be ignored; 101 +1. **Transmission limit: **The data transmission will be stopped automatically after the debugging windows is not closed normally. Only when it is in the debugging window and the switch is on, there is data transmission; 103 103 104 -**1.Interval limit: **When debugging, transfer once every 2~~3 seconds; 105 - 106 -**2.Data limit: **The transfer data cannot be larger than 1.5KB, and the extra part will be ignored; 107 - 108 -**3.Transmission limit: **The data transmission will be stopped automatically after the debugging windows is not closed normally. Only when it is in the debugging window and the switch is on, there is data transmission; 109 - 110 110 Users should pay attention to avoid printing a lot of useless information, should minimize the debug output 111 111 112 112 In addition, please refer to the front-end documentation for how to use view debugging.