项目

一般

简介

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

yangdefeng, 2021-11-03 21:35

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