Sign in to follow this  
Followers 0
TheGh0st

Comparing Ipaddress!

2 posts in this topic

I'm trying to find if an ip address is on the correct group

if @ipaddress1 = "192.168.10.??? <<< ---- PROBLEM HERE of what I need. I don't care what the ??? are as long as its in the

192.168.10 <--- area

MsgBox(0, "IP Address", "Your Internal IP Address is: " & @IPAddress1)

Else

MsgBox(0, "IP Address", "Your External IP Address is: " & $PublicIP)

EndIf

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

Needs a bit of error checking, but...

ConsoleWrite("192.168.10.100: " & SameGroup("192.168.10.100", "192.168.10.1", 3) & @CR)
ConsoleWrite("192.168.20.100: " & SameGroup("192.168.20.100", "192.168.10.1", 3) & @CR)

Func SameGroup($sIPAddress, $sMaster, $iLevel)
  Local $iI, $aIPAddress, $aMaster

  $aIPAddress = StringSplit($sIPAddress, ".")
  $aMaster    = StringSplit($sMaster   , ".")
  for $iI = 1 to $iLevel
    if $aIPAddress[$iI] <> $aMaster[$iI] then
      Return False
    endif
  next
  Return True
EndFunc
Edited by PaulIA

Auto3Lib: A library of over 1200 functions for AutoIt

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