Opt("MustDeclareVars", 1)
#include <Array.au3>
Global Const $sSrcIni = @ScriptDir & "\ipmac.ini", $sTarIni = @ScriptDir & "\new.ini"
If NOT FileExists($sSrcIni) Then Exit 1
ConvMAC()
Exit
Func ConvMAC()
Local $aOldMAC, $aNewMAC[256][2], $sIPPre3, $iElement
$aOldMAC = IniReadSection($sSrcIni, "MAC绑定模块")
If $aOldMAC[0][0] < 1 Then Return SetError(1, 0, 0)
If NOT StringRegExp($aOldMAC[1][0], "^((25[0-5]|2[0-4]\d|[01]?\d?\d)\.){3}(25[0-5]|2[0-4]\d|[01]?\d?\d)$") Then Return SetError(1, 0, 0)
$sIPPre3 = StringLeft($aOldMAC[1][0], StringInStr($aOldMAC[1][0], ".", 0, -1))
For $i = 1 To 255
$aNewMAC[$i][0] = $sIPPre3 & $i
$iElement = _ArraySearch($aOldMAC, $aNewMAC[$i][0], 1)
If @error Then
$aNewMAC[$i][1] = "00-00-00-00-00-00"
Else
$aNewMAC[$i][1] = StringUpper($aOldMAC[$iElement][1])
EndIf
Next
IniWriteSection($sTarIni, "MAC绑定模块", $aNewMAC, 1)
Return
EndFunc ;==>ConvMAC
|