回复 4# afan
感謝Afan兄的代碼,經測試能完美解決,我原使用數組及StringReplace,那速度慢得很,可否幫忙講解一下你的代碼,感謝!
我原來的思路是先將文本1的第3欄分解成1C1.txt, 由1C1.txtr 每行去文本2中找到再寫回文本1,這太慢了。#include<file.au3>
#include<array.au3>
Dim $_file1=@ScriptDir & "\1c1.txt",$_file2=@ScriptDir & "\1.txt",$_file3=@ScriptDir & "\2.txt",$_file4=@ScriptDir & "\datano.txt",$aRecords1,$aRecords2,$aRecords3
_FileReadToArray($_file1,$aRecords1)
_FileReadToArray($_file2,$aRecords2)
_FileReadToArray($_file3,$aRecords3)
For $x=1 To $aRecords1[0]
$_index=0
$_index1=0
If $aRecords1[$x] = "" Then ContinueLoop
$_index=_ArraySearch($aRecords3, $aRecords1[$x],0,0,0,1)
If $_index=-1 Then
FileWriteLine($_file4,$aRecords1[$x])
Else
$_index1=_ArraySearch($aRecords2, $aRecords1[$x],0,0,0,1)
$aRecords2[$_index1]=StringReplace($aRecords2[$_index1],$aRecords1[$x],$aRecords3[$_index])
EndIf
Next
_FileWriteFromArray($_file2, $aRecords2,1)
|