Re: checking form of input
Re: checking form of input
- Subject: Re: checking form of input
- From: has <email@hidden>
- Date: Sat, 30 Nov 2002 12:59:10 +0000
Chris Garaffa wrote:
>
Specifically, i want to make sure that what a user inputs is in the
>
form of an IP address (xxx.yyy.zzz.aaa).
======================================================================
on _makeValidTable()
set str to return
repeat with i from 0 to 255
set str to str & i & return
end repeat
return str
end _makeValidTable
property _validTable : _makeValidTable() -- [uses string instead of
[NO-BREAK]list for speed]
on isIPAddress(str)
if str's class is not in {string, Unicode text} then error "Bad
[NO-BREAK]parameter for isIPAddress: not a string or unicode text."
[NO-BREAK]number -1703
if str's length is less than 7 or str's length is greater than 15
[NO-BREAK]then return false
set oldTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to "."
set lst to str's text items
set AppleScript's text item delimiters to oldTID
if (count of lst) is not 4 then return false
considering case, diacriticals, hyphens, punctuation, expansion
[NO-BREAK]and white space
repeat with subStr in lst
if (return & subStr & return) is not in _validTable then
[NO-BREAK]return false
end repeat
end considering
return true
end isIPAddress
======================================================================
HTH
has
--
http://www.barple.pwp.blueyonder.co.uk -- The Little Page of AppleScripts
_______________________________________________
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.