請選擇 進入手機版 | 繼續訪問電腦版

微剋多資訊

 找回密碼
 註冊

Sign in with google

Google帳號登入

搜索

該用戶從未簽到

升級   0%

發表於 2014-5-22 21:56 | 顯示全部樓層 |閱讀模式
  1. #Region
  2. #AutoIt3Wrapper_icon=Z:NewDang.ico
  3. #AutoIt3Wrapper_Compression=5
  4. #AutoIt3Wrapper_Res_Comment=regedit check
  5. #AutoIt3Wrapper_Res_Description=regedit check
  6. #AutoIt3Wrapper_Res_Fileversion=1.0.0.0
  7. #AutoIt3Wrapper_Res_LegalCopyright=噹噹
  8. #EndRegion


  9. #include <GUIConstantsEx.au3>
  10. #include <Array.au3>

  11. $begin = TimerInit()

  12. Dim $filename_A = FileOpenDialog ( "", @ScriptDir&"", "reg檔 (*.reg)", 7)
  13. Dim $filename_B = FileOpenDialog ( "", @ScriptDir&"", "reg檔 (*.reg)", 7)

  14. Dim $fin = FileOpen ($filename_A, 0)
  15. Dim $context, $line = 0

  16. If $fin = -1 Then;先讀出總數
  17.         MsgBox( 16, "", "ERROR")
  18.         Exit
  19. Else
  20.         While True
  21.                 $context = FileReadLine($fin)
  22.                 If $context <> "" Then
  23.                         $line = $line + 1
  24.                 EndIf
  25.                 If @error = -1 Then ExitLoop
  26.         WEnd
  27.         FileClose($fin)
  28. EndIf

  29. Dim $regLine_A[$line]
  30. ;;--------------預讀A end
  31. $fin = FileOpen ($filename_B, 0)
  32. $line = 0

  33. If $fin = -1 Then;先讀出總數
  34.         MsgBox( 16, "", "ERROR")
  35.         Exit

  36. Else
  37.         While True
  38.                 $context = FileReadLine($fin)
  39.                 If $context <> "" Then
  40.                         $line = $line + 1
  41.                 EndIf
  42.                 If @error = -1 Then ExitLoop
  43.         WEnd
  44.         FileClose($fin)
  45. EndIf

  46. Dim $regLine_B[$line]

  47. $dif_3 = TimerDiff($begin)

  48. ;;--------------預讀B end


  49. Dim $cnt, $Cnt2
  50. Dim $regPath
  51. Dim $regtmp
  52. Dim $regCR = 0

  53. Dim $Array_A = UBound ($regLine_A)

  54. $fin = FileOpen ($filename_A, 0)

  55. If $fin = -1 Then;先讀出總數
  56.         MsgBox( 16, "", "ERROR")
  57. Else
  58.         While True
  59.                 $Cnt2 += 1
  60.                 $context = FileReadLine($fin)
  61.                 If @error = -1 Then ExitLoop
  62.                 If $Cnt2 > $Array_A Then ExitLoop
  63.                 If StringLeft ($context, 1) = "[" And  StringRight ( $context, 1) = "]" Then;; 機碼
  64.                         $context = StringTrimLeft  ($context, 1);; 去掉左邊的 [
  65.                         $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]

  66.                         $regPath = $context

  67. ;~                         ToolTip ($regPath)
  68.                 ElseIf StringLeft ($context, 1) = '"' Or StringLeft ($context, 1) = " " Then;;key值

  69.                         If StringLeft ($context, 1) = '"' And  StringRight ( $context, 1) = "" Then;;斷行第一行
  70.                                 $regCR = 1;; 落行

  71.                                 $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]
  72.                                 $context = StringStripWS($context, 3)

  73.                                 $regtmp = $context
  74. ;~                                 MsgBox (0,"1", $regtmp)
  75.                         ElseIf StringLeft ($context, 1) = " " And  StringRight ( $context, 1) = "" Then;;斷行
  76.                                 $regCR = 1;; 落行

  77.                                 $context = StringTrimLeft  ($context, 1);; 去掉左邊的 [

  78.                                 $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]
  79.                                 $context = StringStripWS($context, 3)

  80.                                 $regtmp = StringFormat ( "%s%s", $regtmp, $context)
  81. ;~                                 MsgBox (0,"2", $regtmp)
  82.                         ElseIf StringLeft ($context, 1) = " " Then;;斷行最後一行

  83.                                 $context = StringStripWS($context, 3)
  84.                                 $context = StringFormat ( "%s%s", $regtmp, $context)
  85.                                 $regCR = 0;;沒斷行
  86.                                 $cnt += 1
  87.                         Else
  88.                                 $regCR = 0;;沒斷行
  89.                                 $cnt += 1
  90.                         EndIf

  91.                         If $regCR = 0 Then;;沒斷行


  92.                                 $context = StringStripCR  ($context);; 去掉CR
  93.                                 $regLine_A[$cnt2] = StringFormat ( "%s_%s", $regPath, $context)
  94.                                 $regtmp = "";;清空斷行暫存
  95. ;~                                 ClipPut ($regLine_A[$cnt])
  96. ;~                                 MsgBox (0,"", $regLine_A[$cnt])
  97. ;~                                 ToolTip ( $Cnt2&@CRLF&@CRLF&$regLine_A[$Cnt2])
  98. ;~                                 Sleep (500)
  99.                         EndIf

  100.                 EndIf

  101.         WEnd
  102.         FileClose($fin)
  103. EndIf


  104. ;;--------------寫入array A end

  105. Dim $Array_B = UBound ($regLine_B)-1
  106. $regCR = 0

  107. $Cnt2 = 0
  108. $Cnt = 0

  109. $fin = FileOpen ($filename_B, 0)

  110. If $fin = -1 Then;先讀出總數
  111.         MsgBox( 16, "", "ERROR")
  112. Else
  113.         While True
  114.                 $Cnt2 += 1

  115.                 $context = FileReadLine($fin)
  116.                 If @error = -1 Then ExitLoop
  117.                 If $Cnt2 > $Array_B Then ExitLoop
  118.                 If StringLeft ($context, 1) = "[" And  StringRight ( $context, 1) = "]" Then;; 機碼
  119.                         $context = StringTrimLeft  ($context, 1);; 去掉左邊的 [
  120.                         $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]
  121.                         $regPath = $context

  122. ;~                         ToolTip ($regPath)
  123.                 ElseIf StringLeft ($context, 1) = '"' Or StringLeft ($context, 1) = " " Then;;key值

  124.                         If StringLeft ($context, 1) = '"' And  StringRight ( $context, 1) = "" Then;;斷行第一行
  125.                                 $regCR = 1;; 落行

  126.                                 $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]
  127.                                 $context = StringStripWS($context, 3)

  128.                                 $regtmp = $context

  129. ;~                                 MsgBox (0,"1", $regtmp)
  130.                         ElseIf StringLeft ($context, 1) = " " And  StringRight ( $context, 1) = "" Then;;斷行
  131.                                 $regCR = 1;; 落行

  132.                                 $context = StringTrimLeft  ($context, 1);; 去掉左邊的 [
  133.                                 $context = StringTrimRight  ($context, 1);; 去掉右邊的 ]
  134.                                 $context = StringStripWS($context, 3)

  135.                                 $regtmp = StringFormat ( "%s%s", $regtmp, $context)
  136. ;~                                 MsgBox (0,"2", $regtmp)
  137.                         ElseIf StringLeft ($context, 1) = " " Then;;斷行最後一行

  138.                                 $context = StringStripWS($context, 3)
  139.                                 $context = StringFormat ( "%s%s", $regtmp, $context)
  140.                                 $regCR = 0;;沒斷行

  141.                                 $cnt += 1
  142.                         Else
  143.                                 $regCR = 0;;沒斷行
  144.                                 $cnt += 1
  145.                         EndIf

  146.                         If $regCR = 0 Then;;沒斷行

  147.                                 $context = StringStripCR  ($context);; 去掉CR
  148. ;~                                 ToolTip ($cnt2)
  149. ;~                                 Sleep (10)
  150.                                 $regLine_B[$cnt2] = StringFormat ( "%s_%s", $regPath, $context)
  151.                                 $regtmp = "";;清空斷行暫存

  152.                         EndIf

  153.                 EndIf
  154.         WEnd
  155.         FileClose($fin)
  156. EndIf

  157. $dif_1 = TimerDiff($begin)

  158. ;;--------------寫入array B end

  159. For $i = 0 To $Array_A-1

  160.         If $regLine_A[$i] = "" Then ContinueLoop
  161.         For $j = 0 To UBound ($regLine_B)-1

  162.                 If $regLine_A[$i] = $regLine_B[$j] Then
  163. ;~                         MsgBox ( 0, "i:"&$i&"___:j"&$j,  $regLine_A[$i]&@CR&$regLine_B[$j])
  164.                         $regLine_A[$i] = ""
  165.                         $regLine_B[$j] = ""
  166.                         ExitLoop(1)
  167.                 EndIf
  168.         Next
  169. Next

  170. $dif_4 = TimerDiff($begin)
  171. ;;--------------比對Array end
  172. const $output_A= "my_output_A.txt"
  173. const $output_B= "my_output_B.txt"

  174. $fout = FileOpen($output_A, 2)

  175. For $i=0 To UBound ($regLine_A)-1
  176.         FileWriteLine($fout, $i&"__"&$regLine_A[$i])
  177. Next

  178. FileClose($fout)

  179. $fout = FileOpen($output_B, 2)

  180. For $i=0 To UBound ($regLine_B)-1
  181.         FileWriteLine($fout, $i&"__"&$regLine_B[$i])
  182. Next

  183. $dif_2 = TimerDiff($begin)

  184. FileWriteLine($fout, StringFormat ("read time:%s sec", $dif_3/1000))
  185. FileWriteLine($fout, StringFormat ("write memory time:%s sec", $dif_1/1000))
  186. FileWriteLine($fout, StringFormat ("search time:%s sec", $dif_4/1000))
  187. FileWriteLine($fout, StringFormat ("write file time:%s sec", $dif_2/1000))

  188. FileClose($fout)
複製代碼
樓主熱門主題
您需要登入後才可以回帖 登入 | 註冊

本版積分規則

小黑屋|Archiver|微剋多資訊(MicroDuo)

GMT+8, 2024-4-18 19:28

Discuz! X

© 2009-2023 Microduo

快速回覆 返回頂部 返回列表