• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Validate IP Address
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Validate IP Address


  • Subject: Re: Validate IP Address
  • From: Timothy Bates <email@hidden>
  • Date: Sun, 12 Feb 2006 20:58:59 +0000
  • Thread-topic: Validate IP Address

IPs are of the form

n.n.n.n

where n is a number between 0 and 255

So you want to
1. Split on "."
2. Count what you get: there should be 4 items
3 Check each item is an integer between 0 and 255

This would be a start
set a to "123.123.123"
set oldDelimiters to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set x to text items of a
set AppleScript's text item delimiters to oldDelimiters
--return count x
if (count x) ‚ 4 then
    display dialog "I need 4 numbers separated by periods (not " & (count x)
& ").

Your string was: " & a

end if

> I'm working on a small apple script which will set a systems IP
> address. I have it pop up a dialog to enter the address and that
> works fine. But What I'm need of is a way to validate the IP address
> is in the correct format.
>
> does anyone have an example on how I can validate the IP address?


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Validate IP Address
      • From: email@hidden (Randal L. Schwartz)
    • Re: Validate IP Address
      • From: Tom Jones <email@hidden>
    • Re: Validate IP Address
      • From: Adam Bell <email@hidden>
References: 
 >Validate IP Address (From: Tom Jones <email@hidden>)

  • Prev by Date: Re: Validate IP Address
  • Next by Date: Replace files
  • Previous by thread: Re: Validate IP Address
  • Next by thread: Re: Validate IP Address
  • Index(es):
    • Date
    • Thread