Sign in to follow this  
Followers 0
Dale2507

_IPCheck Function

Useful   5 members have voted

  1. 1. Was this function useful

    • Yes
      4
    • No
      1

Please sign in or register to vote in this poll.

1 post in this topic

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

Share this post


Link to post
Share on other sites



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 account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0