如何使用AU3读取文件中的关键字符串,批处理移植至AU3??
本帖最后由 tvro 于 2009-7-2 20:13 编辑File1.txt
Forms - 市场部表单 - 部门 = 集团客户组
Forms - 市场部表单 - 姓名 = 张三
Forms - 市场部表单 - 电话 = 1234567
File1.txt
Forms - 计划财务部表单 - 部门 = 计划组
Forms - 计划财务部表单 - 姓名 = 李四
Forms - 计划财务部表单 - 电话 = 4567890
File1.txt
Forms - IT管理部表单 - 部门 = 服务组
Forms - IT管理部表单 - 姓名 = 王五
Forms - IT管理部表单 - 电话 = 5678901
读文件结果到数组:
$var1[市场部表单,集团客户组,张三,1234567]
$var2[计划财务部表单,计划组,李四,4567890]
$var3
以前是用批处理写的,现在想用AU3来读取这个文件,麻烦好心的大老们帮移植哈!!!!!
for /f "delims=- tokens=2" %%p in ('more File1.txt ^| findstr /i /c:"Forms"') do set forms=%%p
for /f "delims== tokens=2" %%p in ('more File1.txt ^| findstr /i /c:"部门"') do set offices=%%p
for /f "delims== tokens=2" %%p in ('more File1.txt ^| findstr /i /c:"姓名"') do set name=%%p
for /f "delims== tokens=2" %%p in ('more File1.txt ^| findstr /i /c:"电话"') do set phone=%%p $linetext = StringStripWS(StringReplace(FileReadLine("File1.txt",1)," = "," - "),8)
$linetextstr = StringSplit($linetext,"-")
msgbox(32,"",$linetextstr)
msgbox(32,"",$linetextstr)
$linetext = StringStripWS(StringReplace(FileReadLine("File1.txt",2)," = "," - "),8)
$linetextstr = StringSplit($linetext,"-")
msgbox(32,"",$linetextstr)
$linetext = StringStripWS(StringReplace(FileReadLine("File1.txt",3)," = "," - "),8)
$linetextstr = StringSplit($linetext,"-")
msgbox(32,"",$linetextstr) dim $Str,$var
$FileHD=FileOpen("File1.txt",0)
$temp1=FileReadLine($FileHD)
$TEMP=StringSplit($temp1,"-")
$var=StringStripWS($TEMP,4)
$temp2=StringSplit($TEMP1,"=")
$var=StringStripWS($temp2,4)
for $i=2 to 3
$Str[$i]=FileReadLine($FileHD)
$TEMP=StringSplit($Str[$i],"=")
$var[$i+1]=StringStripWS($TEMP,4)
Next
FileClose($FileHD)
MsgBox(0,0,$var&","&$var&","&$var&","&$var) 上面两位都是正解 天呀,我都不知道说什么好了,好心的大老们呀,也不知道怎么感谢你们!哭着喊着都不能表达我的感激之情了,谢谢谢谢 哈哈学习了我现在就是想把批处理移植到AU! 楼主真有意思呀。 :face (14):和我照的没太大关系,飘过。。。。
页:
[1]