;------------------------------------------------------------------------------------------------- ; Function _GenerateIPsInRange($IPstart, $IPend, $iRetType=0, $sDelim=Default, $fBroadcast=False) ; Description Erstellt alle möglichen IP's zwischen $IPstart und $IPend ; Parameter $IPstart erste IP im Bereich ; $IPend letzte IP im Bereich ; $iRetType Return-Type 0-Array (Standard), 1-String, trennzeichenbasiert ; $sDelim Trennzeichen bei Stringausgabe, Default= Zeichen von Opt("GuiDataSeparatorChar") ; Return Succes Array 1D (Anzahl in $a[0]) oder String mit allen erstellten IP's ; Failure 0 und set @error 1 : übergebene IP nicht korrekt ; Author BugFix (bugfix@autoit.de) ;---------------------------------------------------------------------------------------------------------------------- Func _GenerateIPsInRange($IPstart, $IPend, $iRetType=0, $sDelim=Default, $fBroadcast=False) If IsKeyword($sDelim) Then $sDelim = Opt("GuiDataSeparatorChar") Local $pattern = '(\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.'& _ '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b)' If ( Not StringRegExp($IPstart, $pattern, 0) Or _ Not StringRegExp($IPend, $pattern, 0) ) Then SetError(1) Return 0 EndIf Local $var = StringSplit($IPstart, '.') Local $o1 = $var[1], $o2 = $var[2], $o3 = $var[3], $o4 = $var[4] $var = StringSplit($IPend, '.') Local $e1 = $var[1], $e2 = $var[2], $e3 = $var[3], $e4 = $var[4] Local $sOut = '', $start = 1, $end = 255 If $fBroadcast Then $start = 0 $end = 256 EndIf While $o1 <= $e1 While ($o2 <= $e2) Or ($o1 < $e1) If $o2 = $end Then $o1 += 1 $o2 = $start EndIf While ($o3 <= $e3) Or ($o2 < $e2) Or ($o1 < $e1) If $o3 = $end Then $o2 += 1 $o3 = $start EndIf While True $sOut &= $o1 &'.'& $o2 &'.'& $o3 &'.'& $o4 & $sDelim If ($o1 = $e1) And ($o2 = $e2) And ($o3 = $e3) And ($o4 = $e4) Then If $iRetType Then Return $sOut Else Return StringSplit(StringTrimRight($sOut, StringLen($sDelim)), $sDelim, 1) EndIf EndIf $o4 += 1 If $o4 = $end Then $o3 += 1 $o4 = $start EndIf WEnd WEnd WEnd WEnd EndFunc ;==>_GenerateIPsInRange