Subject: | |
From: | |
Reply To: | |
Date: | Thu, 19 Mar 2009 21:07:58 -0400 |
Content-Type: | text/plain |
Parts/Attachments: |
|
|
One problem, 06390 is in New York.
On Mar 19, 2009, at 8:57 PM, Mark J. Reed wrote:
> Well, sure. If you don't mind having a massive list in memory, you
> can make it even faster:
>
> property zipCodeList : {}
>
> my setZipCodeList()
>
> on StateFromZip(aZip)
> set position to ((text 1 thru 3 of (aZip as text)) as integer) + 1
> return item position of zipCodeList
> end StateFromZip
>
> on setZipCodeList()
> repeat with i from 0 to 999
> if i >= 006 and i <= 009 then
> set end of zipCodeList to "PR"
> else if i >= 010 and i <= 027 then
> set end of zipCodeList to "MA"
> else if i >= 028 and i <= 029 then
> set end of zipCodeList to "RI"
> else if i >= 030 and i <= 038 then
> set end of zipCodeList to "NH"
> else if i >= 039 and i <= 049 then
> set end of zipCodeList to "ME"
> else if i >= 050 and i <= 059 then
> set end of zipCodeList to "VT"
> else if i >= 060 and i <= 069 then
> set end of zipCodeList to "CT"
> else if i >= 070 and i <= 100 then
> set end of zipCodeList to "NJ"
> else if i >= 101 and i <= 149 then
> set end of zipCodeList to "NY"
> else if i >= 150 and i <= 196 then
> set end of zipCodeList to "PA"
> else if i >= 197 and i <= 199 then
> set end of zipCodeList to "DE"
> else if i >= 200 and i <= 203 then
> set end of zipCodeList to "DC"
> else if i >= 201 and i <= 246 then
> set end of zipCodeList to "VA"
> else if i >= 206 and i <= 219 then
> set end of zipCodeList to "MD"
> else if i >= 247 and i <= 268 then
> set end of zipCodeList to "WV"
> else if i >= 270 and i <= 289 then
> set end of zipCodeList to "NC"
> else if i >= 290 and i <= 299 then
> set end of zipCodeList to "SC"
> else if i >= 300 and i <= 319 then
> set end of zipCodeList to "GA"
> else if i >= 320 and i <= 349 then
> set end of zipCodeList to "FL"
> else if i >= 350 and i <= 388 then
> set end of zipCodeList to "AL"
> else if i >= 370 and i <= 385 then
> set end of zipCodeList to "TN"
> else if i >= 380 and i <= 729 then
> set end of zipCodeList to "AR"
> else if i >= 386 and i <= 397 then
> set end of zipCodeList to "MS"
> else if i >= 400 and i <= 427 then
> set end of zipCodeList to "KY"
> else if i >= 430 and i <= 458 then
> set end of zipCodeList to "OH"
> else if i >= 460 and i <= 479 then
> set end of zipCodeList to "IN"
> else if i >= 480 and i <= 499 then
> set end of zipCodeList to "MI"
> else if i >= 500 and i <= 561 then
> set end of zipCodeList to "IA"
> else if i >= 527 and i <= 629 then
> set end of zipCodeList to "IL"
> else if i >= 530 and i <= 549 then
> set end of zipCodeList to "WI"
> else if i >= 550 and i <= 582 then
> set end of zipCodeList to "MN"
> else if i >= 570 and i <= 577 then
> set end of zipCodeList to "SD"
> else if i >= 576 and i <= 588 then
> set end of zipCodeList to "ND"
> else if i >= 590 and i <= 599 then
> set end of zipCodeList to "MT"
> else if i >= 630 and i <= 658 then
> set end of zipCodeList to "MO"
> else if i >= 660 and i <= 679 then
> set end of zipCodeList to "KS"
> else if i >= 680 and i <= 693 then
> set end of zipCodeList to "NE"
> else if i >= 700 and i <= 714 then
> set end of zipCodeList to "LA"
> else if i >= 730 and i <= 790 then
> set end of zipCodeList to "OK"
> else if i >= 750 and i <= 798 then
> set end of zipCodeList to "TX"
> else if i >= 799 and i <= 884 then
> set end of zipCodeList to "NM"
> else if i >= 800 and i <= 820 then
> set end of zipCodeList to "CO"
> else if i >= 821 and i <= 830 then
> set end of zipCodeList to "WY"
> else if i >= 831 and i <= 991 then
> set end of zipCodeList to "ID"
> else if i >= 840 and i <= 847 then
> set end of zipCodeList to "UT"
> else if i >= 845 and i <= 890 then
> set end of zipCodeList to "AZ"
> else if i >= 891 and i <= 898 then
> set end of zipCodeList to "NV"
> else if i >= 894 and i <= 976 then
> set end of zipCodeList to "CA"
> else if i >= 967 and i <= 968 then
> set end of zipCodeList to "HI"
> else if i >= 970 and i <= 993 then
> set end of zipCodeList to "OR"
> else if i >= 980 and i <= 994 then
> set end of zipCodeList to "WA"
> else if i >= 995 and i <= 999 then
> set end of zipCodeList to "AK"
> else
> set end of zipCodeList to the missing value
> end if
> end repeat
> end setZipCodeList
>
>
> --
> Mark J. Reed <[log in to unmask]>
>
|
|
|