"Stockly, Ed" wrote on Thu, 19 Mar 2009 17:26:38 -0700: > set oldDelims to AppleScript's text item delimiters > set AppleScript's text item delimiters to {""} > set aZip to ((characters 1 thru 3 of aZip) as text) as integer > set AppleScript's text item delimiters to oldDelims Just to be fussy: set aZip to aZip div 100 "Mark J. Reed" wrote on Thu, 19 Mar 2009 20:57:49 -0400: >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 Stuff like this can be optimised to: repeat with i from 0 to 999 if i < 6 then set end of zipCodeList to missing value else if i < 10 then set end of zipCodeList to "PR" else if i < 28 then set end of zipCodeList to "MA" else if i < 30 then > 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" These overlap! ("MD" is eliminated with "VA".) Similarly with much of the stuff below: > 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 NG