Autoit function to Check if an ip address is valid or not
# IsValidIp.au3

#include <Logging.au3>

Func IsValidIp($ip)

	$isValid = 1
	# check using RegExp
	Dim $octets[4]
	$octets = StringRegExp($ip, "(\d+).(\d+).(\d+).(\d+)",1)
	if isArray($octets) then
		llog(@ScriptName, @ScriptLineNumber, $octets[0])
		llog(@ScriptName, @ScriptLineNumber, $octets[1])
		llog(@ScriptName, @ScriptLineNumber, $octets[2])
		llog(@ScriptName, @ScriptLineNumber, $octets[3])
		for $i= 0 to 3
			if $octets[$i] < 0 or $octets[$i] > 255 then
				$isValid = 0
			endif
		next
	else
		$isValid = 0
		llog(@ScriptName, @ScriptLineNumber, $ip & " isNot a valid ip")
	endif
	Llog(@ScriptName, @ScriptLineNumber, $ip & " is valid:" & $isValid)
	return $isValid
	
EndFunc

autoidcheckvalidip.txt · Last modified: 2014/10/25 21:52 (external edit)
CC Attribution-Share Alike 3.0 Unported
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0