Re: Subject: checking form of input
Re: Subject: checking form of input
- Subject: Re: Subject: checking form of input
- From: email@hidden
- Date: Sun, 1 Dec 2002 00:51:58 EST
In a message dated 11/30/02 Chris Garaffa writes
>
Is there a simple way to check the form of input in AppleScript?
>
Specifically, i want to make sure that what a user inputs is in the
>
form of an IP address (xxx.yyy.zzz.aaa). I know that it could be done
>
with regular expressions, perl/grep or something and "do shell script",
>
but I'd rather use AS if possible.
Just set the text item delimiters to "." and break the user's input into a
list of strings. If there aren't four items in the list, it's not an IP
address so you throw an error message right there.
Otherwise, check each string one at a time to see if it contains the correct
number of characters and if it can be coerced to an integer. If it passes all
those tests, it might be an IP address. If not, an error message can help the
user get it right next time.
I'd post an example but I'm too ashamed of my text-item-delimiter habits.
Robert Kyle
Star Tribune
Minneapolis
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.