Re: Validate IP Address
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