项目

一般

简介

多元数组元素变量 » 历史记录 » 版本 2

tejie, 2025-07-14 15:01

1 1 tejie
-
2
-
3
4
h3. 多元数组元素变量
5
6 2 tejie
h4. %{color:fireBrick}不同的作用域写法%
7
8
|L$变量名|私人数组变量|
9
|L$$变量名|全局数组变量|
10
11 1 tejie
h4. %{color:fireBrick}相关命令%
12
13
|取值在数组位置	|[[getListVarIndex]]	|
14
|获取元素数量	|[[getListVarCount]]	|
15
|值是否在数组中	|[[checkVarInList]]	|
16
|数组是否全数字	|[[checkListAllDigit]]	|
17
|获取数组最大值	|[[getListMaxVar]]	|
18
|获取数组最小值	|[[getListMinVar]]	|
19
|数组元素反转	|[[reverseList]]	|
20
|数组元素排序	|[[sortList]]		|
21
22
h4. *%{color:deepskyblue}特戒引擎脚本示例:%*
23
24
bq. %{color:green}<notextile>[@数组赋值]</notextile>%
25
#act
26
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
27
[[print]] 【数组赋值】<$str(L$测试)>
28
<notextile></notextile>
29
%{color:green}<notextile>[@元素取值]</notextile>%
30
#act
31
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
32
%{color:lightGrey};--从左向右取值%
33
[[print]] 【元素取值】<notextile><$str(L$测试[0])>,<$str(L$测试[1])>,<$str(L$测试[2])></notextile>
34
%{color:lightGrey};--从右向左取值%
35
[[print]] 【元素取值】<$str(L$测试[-1])>,<notextile><$str(L$测试[-2])>,<$str(L$测试[-3])></notextile>
36
<notextile></notextile>
37
%{color:green}<notextile>[@元素改值]</notextile>%
38
#act
39
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
40
[[mov]] <notextile>L$测试[0]</notextile> 00
41
[[print]] 【元素改值】<$str(L$测试)>
42
<notextile></notextile>
43
[[mov]] L$测试2 [aa,bb,cc]
44
[[mov]] <notextile>L$测试[0]</notextile> <$str(L$测试2)>
45
[[print]] 【元素改值】<$str(L$测试)>
46
<notextile></notextile>
47
%{color:green}[@增加元素]%
48
#act
49
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
50
[[inc]] L$测试 bb
51
[[print]] 【增加元素】<$str(L$测试)>
52
<notextile></notextile>
53
%{color:green}<notextile>[@删除元素]</notextile>%
54
#act
55
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
56
[[dec]] L$测试 22
57
[[print]] 【删除元素】<$str(L$测试)>
58
<notextile></notextile>
59
%{color:green}<notextile>[@元素下标变量]</notextile>%
60
#act
61
[[mov]] L$测试 [1,2,3]
62
[[mov]] N1 1
63
[[mov]] L$测试[<$str(n1)>] 23
64
[[print]] 【元素下标变量1】<$str(L$测试)>
65
[[print]] 【元素下标变量2】<$str(L$测试[<$str(n1)>])>
66
<notextile></notextile>
67
%{color:green}<notextile>[@元素清空]</notextile>%
68
#if
69
#act
70
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
71
[[mov]] L$测试 []
72
[[print]] 【元素清空】<$str(L$测试)>
73
<notextile></notextile>
74
[[mov]] L$测试 [11,22,33,44,55,66,77,aa]
75
[[mov]] L$测试
76
[[print]] 【元素清空】<$str(L$测试)>
77
<notextile></notextile>
78
%{color:green}<notextile>[@变量传值]</notextile>%
79
#if
80
#act
81
[[mov]] L$测试 [1,2,3]
82
[[goto]] <notextile>@</notextile>变量传值(<$str(L$测试)>)
83
<notextile>[@变量传值]</notextile>
84
#if
85
#act
86
[[print]] 【变量传值】<$scriptParam1>