项目

一般

简介

字符串 » 历史记录 » 版本 18

yangdefeng, 2021-11-03 21:16

1 1 yangdefeng
{{toc}}
2
3
h3. 字符串
4
5 18 yangdefeng
h4. _%{color:green}getListString%_
6
7
*读取文本中指定行的内容*
8
9
格式:
10
getListString ..\QuestDiary\NewFile.txt 0 <notextile>S$tmp</notextile>
11
12
说明:读取文本文件指定行的内容
13
14
----
15
16 1 yangdefeng
h4. *_%{color:green}pgExtractString%_*
17
18
字符串分割
19
20
格式:
21
22
|命令名         |参数1 |参数2   |参数3 |参数4 |
23
|pgExtractString|分割符|分割对象|变量名|变量名|
24
25
说明:
26
* 参数1:自定义的分割符
27
* 参数2:待分割的字符串
28
* 参数3:存放分割结果的变量列表,变量名_1、变量名_2、依次类推
29
* 参数4:存放分割数量
30
31
bq. %{color:lightgrey};用例1:%
32
[@main]
33
#if
34
#act
35
pgExtractString | 测试文本1|测试文本2 S$测试变量 N0
36
<notextile>sendMsg 6 你将文本分割了,并将分割后的内容保存在变量【S$测试变量_1】和【S$测试变量_2】中,他们的值分别是<$STR(S$测试变量_1)>和<$STR(S$测试变量_2)>,分割后共获得了【<$STR(N0)>】个内容</notextile>
37
%{color:lightgrey};--%
38
%{color:lightgrey};用例:2%
39
[@main]
40
#act
41
mov N$幸运等级 <$str(U1017)>
42
dec N$幸运等级 1
43
%{color:lightgrey};读取文件指定行%
44
getListString ..\QuestDiary\幸运项链\数据表.txt <$str(N$幸运等级)> S$返回串
45
%{color:lightgrey};对字符串分割取值%
46
pgExtractString | S$返回串 S$返回值 N$分割数
47
<notextile>mov N$幸运倍攻加成 <$STR(S$返回值_6)></notextile>
48
49
----
50
51
h4. *_%{color:green}extractString%_*
52
53
格式:
54
说明:
55
56
bq. 用例:
57
#act
58
mov S0 战神盔甲(男):裁决之杖:绿色项链:黑铁头盔:骑士手镯:骑士手镯:力量戒指:力量戒指
59
<notextile>extractString : <$STR(S0)> s1 s2 s3 s4 s5 s6 s7 s8</notextile>
60
<notextile>sendmsg 6 分割结果:<$STR(S1)> <$STR(S2)> <$STR(S3)> <$STR(S4)> <$STR(S5)> <$STR(S6)> <$STR(S7)> <$STR(S8)></notextile>
61
62
----
63
64
h4. _*%{color:green}ansiReplaceText%*_
65
66
字符串替换
67
68
格式:
69
70
|命令名         |参数1      |参数2   |参数3  |
71
|ANSIREPLACETEXT|字符串变量 |旧字符串| 新字符|
72
73
说明:
74
75
* 参数1:
76
* 参数2:
77
* 参数3:
78
79
----
80
81
h4. *_%{color:green}getStringPos%_*
82
83
*取字符串在列表中的位置*
84
取字符串在列表中的下标
85
86
格式:getStringPos ..\QuestDiary\测试.txt 管理员
87
说明:
88
89
sendMsg 6 字符串在列表中的位置:<notextile><$STR(N0)></notextile>
90
91
----
92
93
h4. *_%{color:green}addTextListEx%_*
94
95
*字符串写入文件*
96
97
格式:
98
99
|_.命令名     |_.参数1|_.参数2 |_.参数3 |
100
|addTextListEx|路径   |写入文本|写入行号|
101
102
说明:
103
* 参数1:支持变量传值
104
* 参数2:支持变量传值
105
106
bq. 用例:
107
addTextListEx ..\QuestDiary\TestList.txt <$USERNAME> 0
108
109
110
*_%{color:green}addTextList%_*
111
格式:AddTextList ..\TestList.txt 您的名字
112
格式:AddTextList ..\TestList.txt 您的名字 您的性别
113
说明:无行号
114
115
----
116
117
h4. _%{color:green}delTextList%_
118
119
*删除文件中的字符串*
120
121
格式:DelTextList ..\TestList.txt 您的名字
122
格式:DelTextList ..\TestList.txt 您的名字 您的性别
123
124
----
125
126
h4. _%{color:green}inc%_
127
128
*字符串加法*
129
130
格式:
131
inc 字符串1 字符串2
132
133
说明:
134
135
----
136
137
h4. _%{color:green}dec%_
138
139
*字符串减法*
140
141
格式:
142
dec 字符串1 字符串2
143
144
说明:
145
146
----
147
148
h4. _%{color:green}compareText%_
149
150
*字符串比对*
151
152
格式:
153
CompareText 字符串1 字符串2
154
155
说明:
156
157
例子:
158
CompareText <$KILLMONNAME> 宝藏守卫者
159
160
----
161
162
h4. _*%{color:green}setStringBlank%*_
163
164
格式:
165
166
|命令名        |参数1|参数2|参数3|
167
|setStringBlank|变量 |长度 |前后 |
168
169
说明:
170
171
* 参数1:变量支持A与S
172
* 参数2:设定变量固定长度
173
** 单个字母1个长度
174
** 单个汉字2个长度
175
* 参数3:前置或后置补空格
176
** 0,前置
177
** 1,后置
178
179
bq. 用例:
180
mov S10 gameofmir引擎
181
<notextile>setStringBlank <$STR(S10)> 20 0</notextile>
182
;字符串原长度13
183
;给字符串前面补7个空格
184
185
----
186
187 2 yangdefeng
h3. 字符串随机
188
189 8 yangdefeng
h4. _%{color:green}getRandomText%_
190
191
*从文件中随机获取一行字符串*
192
193
格式: 
194
GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000)
195
196
说明: 
197 9 yangdefeng
未指定行时,随机取某一行的字符串.
198 8 yangdefeng
199
----
200
201 2 yangdefeng
h4. _%{color:green}getRandomLineText%_
202 6 yangdefeng
203
*从文件中随机取文本*
204
205 1 yangdefeng
格式:
206
207 8 yangdefeng
|命令名           |参数1|参数2|
208
|getRandomLineText|路径 |变量 |
209 1 yangdefeng
210
211 8 yangdefeng
说明:
212 6 yangdefeng
213 10 yangdefeng
bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值%
214
#act
215 1 yangdefeng
mov S$tmp 1一大陆武器
216
<notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile>
217 10 yangdefeng
%{color:lightgrey}用例2:%
218
#act
219 8 yangdefeng
getRandomLineText ..\QuestDiary\装备列表.txt S0
220 6 yangdefeng
221
----
222 2 yangdefeng
223 1 yangdefeng
h3. 字符串检测
224 12 yangdefeng
225
h4. _%{color:green}checkStringlength%_
226
227
*检测字符串长度*
228
229
格式:
230
checkStringlength 字符串 操作符(<,>,=) 位数
231
232
说明:一个汉字位数为2
233
234
bq. 用例:
235
[@test]
236
#IF
237 14 yangdefeng
checkStringlength D3dm2 > 3
238
#act
239
sendMsg 6 D3dm2大于3个字符
240 1 yangdefeng
#ELSESAY
241 14 yangdefeng
sendMsg 6 D3dm2小于3个字符
242
243
----
244
245
h4. _%{color:green}checkTextList%_
246
247
*检查字符串是否在指定文件中*
248
249
格式:
250
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile>
251
252
说明:
253
254
格式:
255
CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile>
256
257
说明:
258
S$2和S$3的值在“10元卡号.txt”文本中以空格分开
259 12 yangdefeng
260
----
261 16 yangdefeng
262
h4. _*%{color:green}checkContainsText%*_
263
264
*检查字符串A是否包涵字符串B*
265
266
格式:
267
checkContainsText 字符串A 字符串B
268
269
说明:
270
271
bq. 用例:
272
#if
273
<notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile>
274
#act
275
sendMsg 6 包涵
276
#elseAct
277
sendMsg 6 不包涵
278
279
----