字符串 » 历史记录 » 版本 21
yangdefeng, 2021-11-03 21:22
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 | ---- |
||
88 | |||
89 | h4. *_%{color:green}getStringPos%_* |
||
90 | |||
91 | 21 | yangdefeng | *取字符串在列表中的位置(下标)* |
92 | 1 | yangdefeng | |
93 | 格式:getStringPos ..\QuestDiary\测试.txt 管理员 |
||
94 | 说明: |
||
95 | |||
96 | sendMsg 6 字符串在列表中的位置:<notextile><$STR(N0)></notextile> |
||
97 | |||
98 | ---- |
||
99 | |||
100 | h4. *_%{color:green}addTextListEx%_* |
||
101 | |||
102 | *字符串写入文件* |
||
103 | |||
104 | 格式: |
||
105 | |||
106 | |_.命令名 |_.参数1|_.参数2 |_.参数3 | |
||
107 | |addTextListEx|路径 |写入文本|写入行号| |
||
108 | |||
109 | 说明: |
||
110 | * 参数1:支持变量传值 |
||
111 | * 参数2:支持变量传值 |
||
112 | |||
113 | bq. 用例: |
||
114 | addTextListEx ..\QuestDiary\TestList.txt <$USERNAME> 0 |
||
115 | |||
116 | |||
117 | *_%{color:green}addTextList%_* |
||
118 | 格式:AddTextList ..\TestList.txt 您的名字 |
||
119 | 格式:AddTextList ..\TestList.txt 您的名字 您的性别 |
||
120 | 说明:无行号 |
||
121 | |||
122 | ---- |
||
123 | |||
124 | h4. _%{color:green}delTextList%_ |
||
125 | |||
126 | *删除文件中的字符串* |
||
127 | |||
128 | 格式:DelTextList ..\TestList.txt 您的名字 |
||
129 | 格式:DelTextList ..\TestList.txt 您的名字 您的性别 |
||
130 | |||
131 | ---- |
||
132 | |||
133 | h4. _%{color:green}inc%_ |
||
134 | |||
135 | *字符串加法* |
||
136 | |||
137 | 格式: |
||
138 | inc 字符串1 字符串2 |
||
139 | |||
140 | 说明: |
||
141 | |||
142 | ---- |
||
143 | |||
144 | h4. _%{color:green}dec%_ |
||
145 | |||
146 | *字符串减法* |
||
147 | |||
148 | 格式: |
||
149 | dec 字符串1 字符串2 |
||
150 | |||
151 | 说明: |
||
152 | |||
153 | ---- |
||
154 | |||
155 | h4. _%{color:green}compareText%_ |
||
156 | |||
157 | *字符串比对* |
||
158 | |||
159 | 格式: |
||
160 | CompareText 字符串1 字符串2 |
||
161 | |||
162 | 说明: |
||
163 | |||
164 | 例子: |
||
165 | CompareText <$KILLMONNAME> 宝藏守卫者 |
||
166 | |||
167 | ---- |
||
168 | |||
169 | h4. _*%{color:green}setStringBlank%*_ |
||
170 | |||
171 | 格式: |
||
172 | |||
173 | |命令名 |参数1|参数2|参数3| |
||
174 | |setStringBlank|变量 |长度 |前后 | |
||
175 | |||
176 | 说明: |
||
177 | |||
178 | * 参数1:变量支持A与S |
||
179 | * 参数2:设定变量固定长度 |
||
180 | ** 单个字母1个长度 |
||
181 | ** 单个汉字2个长度 |
||
182 | * 参数3:前置或后置补空格 |
||
183 | ** 0,前置 |
||
184 | ** 1,后置 |
||
185 | |||
186 | bq. 用例: |
||
187 | mov S10 gameofmir引擎 |
||
188 | <notextile>setStringBlank <$STR(S10)> 20 0</notextile> |
||
189 | ;字符串原长度13 |
||
190 | ;给字符串前面补7个空格 |
||
191 | |||
192 | ---- |
||
193 | |||
194 | 2 | yangdefeng | h3. 字符串随机 |
195 | |||
196 | 8 | yangdefeng | h4. _%{color:green}getRandomText%_ |
197 | |||
198 | *从文件中随机获取一行字符串* |
||
199 | |||
200 | 格式: |
||
201 | GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000) |
||
202 | |||
203 | 说明: |
||
204 | 9 | yangdefeng | 未指定行时,随机取某一行的字符串. |
205 | 8 | yangdefeng | |
206 | ---- |
||
207 | |||
208 | 2 | yangdefeng | h4. _%{color:green}getRandomLineText%_ |
209 | 6 | yangdefeng | |
210 | *从文件中随机取文本* |
||
211 | |||
212 | 1 | yangdefeng | 格式: |
213 | |||
214 | 8 | yangdefeng | |命令名 |参数1|参数2| |
215 | |getRandomLineText|路径 |变量 | |
||
216 | 1 | yangdefeng | |
217 | |||
218 | 8 | yangdefeng | 说明: |
219 | 6 | yangdefeng | |
220 | 10 | yangdefeng | bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值% |
221 | #act |
||
222 | 1 | yangdefeng | mov S$tmp 1一大陆武器 |
223 | <notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile> |
||
224 | 10 | yangdefeng | %{color:lightgrey}用例2:% |
225 | #act |
||
226 | 8 | yangdefeng | getRandomLineText ..\QuestDiary\装备列表.txt S0 |
227 | 6 | yangdefeng | |
228 | ---- |
||
229 | 2 | yangdefeng | |
230 | 1 | yangdefeng | h3. 字符串检测 |
231 | 12 | yangdefeng | |
232 | h4. _%{color:green}checkStringlength%_ |
||
233 | |||
234 | *检测字符串长度* |
||
235 | |||
236 | 格式: |
||
237 | checkStringlength 字符串 操作符(<,>,=) 位数 |
||
238 | |||
239 | 说明:一个汉字位数为2 |
||
240 | |||
241 | bq. 用例: |
||
242 | [@test] |
||
243 | #IF |
||
244 | 14 | yangdefeng | checkStringlength D3dm2 > 3 |
245 | #act |
||
246 | sendMsg 6 D3dm2大于3个字符 |
||
247 | 1 | yangdefeng | #ELSESAY |
248 | 14 | yangdefeng | sendMsg 6 D3dm2小于3个字符 |
249 | |||
250 | ---- |
||
251 | |||
252 | h4. _%{color:green}checkTextList%_ |
||
253 | |||
254 | *检查字符串是否在指定文件中* |
||
255 | |||
256 | 格式: |
||
257 | CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile> |
||
258 | |||
259 | 说明: |
||
260 | |||
261 | 格式: |
||
262 | CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile> |
||
263 | |||
264 | 说明: |
||
265 | S$2和S$3的值在“10元卡号.txt”文本中以空格分开 |
||
266 | 12 | yangdefeng | |
267 | ---- |
||
268 | 16 | yangdefeng | |
269 | h4. _*%{color:green}checkContainsText%*_ |
||
270 | |||
271 | *检查字符串A是否包涵字符串B* |
||
272 | |||
273 | 格式: |
||
274 | checkContainsText 字符串A 字符串B |
||
275 | |||
276 | 说明: |
||
277 | |||
278 | bq. 用例: |
||
279 | #if |
||
280 | <notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile> |
||
281 | #act |
||
282 | sendMsg 6 包涵 |
||
283 | #elseAct |
||
284 | sendMsg 6 不包涵 |
||
285 | |||
286 | ---- |