项目

一般

简介

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

yangdefeng, 2021-11-03 21:19

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