项目

一般

简介

字符串 » 历史记录 » 修订 26

修订 25 (yangdefeng, 2021-11-03 21:50) → 修订 26/30 (yangdefeng, 2021-11-03 21:51)

{{toc}} 

 h3. 字符串 

 h4. _%{color:green}getListString%_ 

 *读取文本中指定行的内容* 

 *格式:* 
 |命令名         |参数1     |参数2|参数3| 
 |getListString|文件路径|行号 |变量 | 

 *说明:* 
 读取文本文件指定行的内容,存入指定变量 

 bq. %{color:lightgrey}用例:% 
 #act 
 getListString ..\QuestDiary\NewFile.txt 0 <notextile>S$tmp</notextile> 



 ---- 

 h4. *_%{color:green}pgExtractString%_* 

 字符串分割 

 格式: 

 |命令名           |参数1 |参数2     |参数3 |参数4 | 
 |pgExtractString|分割符|分割对象|变量名|变量名| 

 说明: 
 * 参数1:自定义的分割符 
 * 参数2:待分割的字符串 
 * 参数3:存放分割结果的变量列表,变量名_1、变量名_2、依次类推 
 * 参数4:存放分割数量 

 bq. %{color:lightgrey};用例1:% 
 [@main] 
 #if 
 #act 
 pgExtractString | 测试文本1|测试文本2 S$测试变量 N0 
 <notextile>sendMsg 6 你将文本分割了,并将分割后的内容保存在变量【S$测试变量_1】和【S$测试变量_2】中,他们的值分别是<$STR(S$测试变量_1)>和<$STR(S$测试变量_2)>,分割后共获得了【<$STR(N0)>】个内容</notextile> 
 %{color:lightgrey};--% 
 %{color:lightgrey};用例:2% 
 [@main] 
 #act 
 mov N$幸运等级 <$str(U1017)> 
 dec N$幸运等级 1 
 %{color:lightgrey};读取文件指定行% 
 getListString ..\QuestDiary\幸运项链\数据表.txt <$str(N$幸运等级)> S$返回串 
 %{color:lightgrey};对字符串分割取值% 
 pgExtractString | S$返回串 S$返回值 N$分割数 
 <notextile>mov N$幸运倍攻加成 <$STR(S$返回值_6)></notextile> 

 ---- 

 h4. *_%{color:green}extractString%_* 

 格式: 
 |命令名         |参数1 |参数2         |参数3|参数4|参数5|参数6|参数7|参数8|参数9|参数10| 
 |extractString|分割符|待分割字符串|变量1|变量2|变量3|变量4|变量5|变量6|变量7|变量8 | 

 说明: 
 按照指定分割符分割字符串,并存入多个变量中 

 bq. %{color:lightgrey}用例:% 
 #act 
 mov S0 战神盔甲(男):裁决之杖:绿色项链:黑铁头盔:骑士手镯:骑士手镯:力量戒指:力量戒指 
 <notextile>extractString : <$STR(S0)> s1 s2 s3 s4 s5 s6 s7 s8</notextile> 
 <notextile>sendmsg 6 分割结果:<$STR(S1)> <$STR(S2)> <$STR(S3)> <$STR(S4)> <$STR(S5)> <$STR(S6)> <$STR(S7)> <$STR(S8)></notextile> 

 ---- 

 h4. _*%{color:green}ansiReplaceText%*_ 

 字符串替换 

 格式: 

 |命令名           |参数1        |参数2     |参数3    | 
 |ANSIREPLACETEXT|字符串变量 |旧字符串| 新字符| 

 说明: 

 * 参数1:待处理的字符串 
 * 参数2:待处理的字符串中需要换掉的内容 
 * 参数3:待处理的字符串中需要换入的内容 

 bq. %{color:lightgrey}用例: 
 ;把www.top166.com替换成 qq.com 
 % 
 [@main] 
 #if  
 #act 
 mov S0 <notextile>www.top166.com</notextile> 
 ansiReplaceText S0 <notextile>www.top166</notextile> qq 
 sendmsg 6 <notextile><$STR(S0)></notextile> 

 ---- 

 h4. *_%{color:green}getStringPos%_* 

 *取字符串在列表中的位置(下标)* 

 格式: 
 |命令名        |参数1     |参数2     | 
 |getStringPos|文件路径|查找内容| 


 说明: 
 返回值放在N0变量中, 
 如果N0=9999999说明没有找到. 

 bq. %{color:lightgrey}用例:% 
 #act 
 getStringPos ..\QuestDiary\测试.txt 管理员 
 sendMsg 6 字符串在列表中的位置:<notextile><$STR(N0)></notextile> 

 ---- 

 h4. *_%{color:green}addTextListEx%_* 

 *字符串写入文件* 

 格式: 

 |_.命令名       |_.参数1|_.参数2 |_.参数3 | 
 |addTextListEx|路径     |写入文本|写入行号| 

 说明: 
 * 参数1:支持变量传值 
 * 参数2:支持变量传值 

 bq. 用例: 
 addTextListEx ..\QuestDiary\TestList.txt <$USERNAME> 0 


 *_%{color:green}addTextList%_* 
 格式:AddTextList ..\TestList.txt 您的名字 
 格式:AddTextList ..\TestList.txt 您的名字 您的性别 
 说明:无行号 

 ---- 

 h4. _%{color:green}delTextList%_ 

 *删除文件中的字符串* 

 格式:DelTextList ..\TestList.txt 您的名字 
 格式:DelTextList ..\TestList.txt 您的名字 您的性别 

 ---- 

 h4. _%{color:green}inc%_ 

 *字符串加法* 

 格式: 
 inc 字符串1 字符串2 

 说明: 

 ---- 

 h4. _%{color:green}dec%_ 

 *字符串减法* 

 格式: 
 dec 字符串1 字符串2 

 说明: 

 ---- 

 h4. _%{color:green}compareText%_ 

 *字符串比对* 

 格式: 
 CompareText 字符串1 字符串2 

 说明: 

 例子: 
 CompareText <$KILLMONNAME> 宝藏守卫者 

 ---- 

 h4. _*%{color:green}setStringBlank%*_ 

 格式: 

 |命令名          |参数1|参数2|参数3| 
 |setStringBlank|变量 |长度 |前后 | 

 说明: 

 * 参数1:变量支持A与S 
 * 参数2:设定变量固定长度 
 ** 单个字母1个长度 
 ** 单个汉字2个长度 
 * 参数3:前置或后置补空格 
 ** 0,前置 
 ** 1,后置 

 bq. 用例: 
 mov S10 gameofmir引擎 
 <notextile>setStringBlank <$STR(S10)> 20 0</notextile> 
 %{color:lightgrey};字符串原长度13 ;字符串原长度13 
 ;给字符串前面补7个空格% ;给字符串前面补7个空格 

 ---- 

 h3. 字符串随机 

 h4. _%{color:green}getRandomText%_ 

 *从文件中随机获取一行字符串* 

 格式:  
 GetRandomText 文件路径 变量(S0--S99) 指定行(0-10000) 

 说明:  
 未指定行时,随机取某一行的字符串. 

 ---- 

 h4. _%{color:green}getRandomLineText%_ 

 *从文件中随机取文本* 

 格式: 

 |命令名             |参数1|参数2| 
 |getRandomLineText|路径 |变量 | 


 说明: 

 bq. %{color:lightgrey}用例1:从文件..\QuestDiary\配置文件\1一大陆武器.txt中随机取值% 
 #act 
 mov S$tmp 1一大陆武器 
 <notextile>getRandomLineText ..\QuestDiary\配置文件\<$STR(S$tmp)>.txt S$武器</notextile> 
 %{color:lightgrey}用例2:% 
 #act 
 getRandomLineText ..\QuestDiary\装备列表.txt S0 

 ---- 

 h3. 字符串检测 

 h4. _%{color:green}checkStringlength%_ 

 *检测字符串长度* 

 格式: 
 checkStringlength 字符串 操作符(<,>,=) 位数 

 说明:一个汉字位数为2 

 bq. 用例: 
 [@test] 
 #IF 
 checkStringlength D3dm2 > 3 
 #act 
 sendMsg 6 D3dm2大于3个字符 
 #ELSESAY 
 sendMsg 6 D3dm2小于3个字符 

 ---- 

 h4. _%{color:green}checkTextList%_ 

 *检查字符串是否在指定文件中* 

 格式: 
 CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)></notextile> 

 说明: 

 格式: 
 CHECKTEXTLIST ..\QuestDiary\充值系统\10元卡号.txt <notextile><$STR(S$2)> <$STR(S$3)></notextile> 

 说明: 
 S$2和S$3的值在“10元卡号.txt”文本中以空格分开 

 ---- 

 h4. _*%{color:green}checkContainsText%*_ 

 *检查字符串A是否包涵字符串B* 

 格式: 
 checkContainsText 字符串A 字符串B 

 说明: 

 bq. 用例: 
 #if 
 <notextile>checkContainsText www.gameofmir.com gameofmir.com</notextile> 
 #act 
 sendMsg 6 包涵 
 #elseAct 
 sendMsg 6 不包涵 

 ----