Jump to content

Comparing Ipaddress!


 Share

Recommended Posts

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

Link to comment
Share on other sites

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
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...