User guide

12
E SR SCRIPT RM
Array operation
Others
Function name Argument Return value Applicable model
table.concat(tbl,se
p,i,j)
tbl: array name
sep: character
(1 character)
i: numerical
value
j: numerical
value
Character strings combined
after the data from tbl[i] to l[j] in
the array (tbl) is delimited by
sep.
table.insert(tbl,i,v
)
tbl: array name
i: numerical
value
v: numerical
value
Inserts v into the tbl[i] position
in the array (tbl).
Elements following the ith
position are moved backward
by one.
No return value.
table.maxn(tbl) tbl: array name
Returns the largest index value
in the array (tbl).
table.remove(tbl.i
)
tbl: array name
i: numerical
value
Deletes the element at the tbl[i]
position in the array (tbl).
Elements following the ith
position are moved forward by
one.
No return value.
table.sort(tbl) tbl: array name
Sorts the elements in the array
(tbl).
No return value.
Function name Argument Return value Applicable model
assert( v,mes)
v: judgment
mes: character string
If v is False, mes is output.
The program is force-quit.
error("",1) -
Errors (ScriptError) out
explicitly and terminates the
program.
print(mes)
mes: character string
Outputs messages for debug.
tonumber(v) v: value
Converts to numerical values.
Returns nil if value conversion
is not possible.
tostring(v) v: value Converts to character strings.
type(v) v: value Variable type
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
1000
D100
750
700
5-5 User-defined function
This section describes functions that can be uniquely defined by users.
User-defined function
Format
z Definition of function
z Calling the function
function function name (argument)
Variable declaration
Process
return(variable) The value entered into return is the return value.
end
Function name (value)
Example 1
function readformatEvent()
local a Declares variable a.
a= test_1() Stores the result of test_1() in variable a.
a = a .. "ABC" Appends character string "ABC" to variable a.
return(a) Outputs the result.
end
function test_1() Defines the user-defined function test_1().
local c Declares variable c.
c = 123 Assigns "123" to variable c.
return(c) The value of variable c is the return value.
end
Execution result 123ABC