回复 3# tsys
#include <Array.au3>
$aNumbers=IniReadSection("config.ini","config")
_ArrayDisplay($aNumbers)
$aUnique = ArrayUnique($aNumbers,1,0,1)
_ArrayDisplay($aUnique)
If MsgBox(4,"","覆盖原文件(是)"&@CRLF&"新建INI文件(否)") = 6 Then
IniDelete("config.ini","config")
IniWriteSection("config.ini","config",$aUnique,1)
Else
IniWriteSection("config2.ini","config",$aUnique,1)
EndIf
Exit
Func ArrayUnique($aArray, $iBase = 0, $oBase = 0, $iCol = 0);数组,开始索引,结束索引,列
If Not IsArray($aArray) Then Return SetError(1, 0, 0)
If UBound($aArray, 0) > 2 Then Return SetError(2, 0, 0)
Local $oD = ObjCreate('Scripting.Dictionary')
If @error Then Return SetError(4, 0, 0)
Local $dim2 = UBound($aArray, 2), $i
If $dim2 Then ;2D array
Local $dim1 = UBound($aArray, 1)
Local $aUnique[$dim1][$dim2], $j=$iBase
If $oBase=0 Then $oBase = $dim1-1
For $i = $iBase to $oBase
If Not $oD.Exists($aArray[$i][$iCol]) Then
$oD.Add($aArray[$i][$iCol], 0)
$aUnique[$j][0] = $aArray[$i][0]
$aUnique[$j][1] = $aArray[$i][1]
$j += 1
EndIf
Next
ReDim $aUnique[$j][2]
$aUnique[0][0]=UBound($aUnique)
Else ;1D array
For $i In $aArray
If Not $oD.Exists($i) Then $oD.Add($i, 0)
Next
Local $aUnique = $oD.Keys()
EndIf
$oD.RemoveAll
$oD = ""
Return SetError(0, 0, $aUnique)
EndFunc
|