Dale2507 Posted June 30, 2007 Share Posted June 30, 2007 Here's a small function i made to check if an ip address is in the valid format CODE ;=============================================================================== ; ; Description: IP format check ; Syntax: _IPCheck($IP) ; Parameter(s): $IP: The IP to check ; Requirement(s): None ; Return Value(s): Returns @error and @extended values ; @error = 1 if not enough sections (e.g. '154.176.12' must be 4 sections) ; @extended = number of sections ; @error = 2 if section number is too large (e.g. '3543' must be below 256) ; @extended = first section which produced error ; @error = 3 if section number is too small (e.g. '-231' must be equal to or above 0) ; @extended = first section which produced error ; Author(s): Gmail ; ;=============================================================================== Func _IPCheck ($IP) $split = StringSplit ($IP, ".") If $Split[0] <> 4 Then SetError (1, $Split[0]) $i = 1 Do If @error <> 1 And @error <> 2 And @error <> 3 Then If $split[$i] > 255 Then SetError (2, $i) If @error <> 2 Then If $split[$i] < 0 Then SetError (3, $i) EndIf EndIf $i += 1 Until $i > 4 EndFunc Deal or No Deal? Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now