Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!


Click here to return to the 'Updated Script' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Updated Script
Authored by: staypuft on Jan 20, '05 04:22:28PM
I updated the script to strip apartment numbers from the address field. This only works if you list apartment and suite numbers as 123 street #7 and not 123 street apartment 7. I also changed it to format the query as street, city, state, zip instead of street zip city. Route 66 seems to work fine with either formatting, it was just a personal preference.
property _version : "ROUTE 66 Route 2004"
property _subversion : "ROUTE 66 Route 2004"

using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for _person with _address
		return "Find Address in Route66"
	end action title
	
	on should enable action for _person with _address
		return true
	end should enable action
	
	on perform action for _person with _address
		set theresult to my getaddress_of_selection() as list
		if item 1 of theresult is {} and item 2 of theresult is {} and item 3 of theresult is {} and item 4 of theresult is {} then
			display dialog "\"No Address entry found\"" buttons {"OK"} default button 1 with icon 2
		else
			set addr to item 1 of theresult & ", " & item 2 of theresult & ", " & item 3 of theresult & ", " & item 4 of theresult as string
			try
				tell application _version to activate
			end try
			tell application "System Events"
				repeat 20 times
					if application process _subversion exists then
						exit repeat
					end if
				end repeat
			end tell
			try
				tell application _subversion to activate
				tell application "System Events"
					tell application process _subversion
						set value of combo box 1 of tab group 1 of splitter group 1 of splitter group 2 of window 1 to addr
						delay 0.5
						click button 2 of tab group 1 of splitter group 1 of splitter group 2 of window 1
					end tell
				end tell
			on error
				display dialog "ERROR - GUI scripting enabled?" with icon 2
			end try
		end if
	end perform action
end using terms from

on getaddress_of_selection()
	tell application "Address Book"
		set sellist to selection
		set oneentry to item 1 of sellist
		set oneentry to id of oneentry
		set str to street of address of person id oneentry as string
		set thezip to zip of address of person id oneentry
		set cit to city of address of person id oneentry
		set sta to state of address of person id oneentry
	end tell
	if str is {missing value} then
		set str to "" as string
	else
		repeat with Num from 1 to length of str by 1
			if get character Num of str is equal to "#" then
				set str to (get text 1 through (Num - 2) of str)
				display dialog "Apartment Number was stripped" with icon 2
				exit repeat
			end if
		end repeat
	end if
	if thezip is {missing value} then set thezip to "" as string
	if cit is {missing value} then set cit to "" as string
	if sta is {missing value} then set sta to "" as string
	return {str, cit, sta, thezip}
end getaddress_of_selection


[ Reply to This | # ]
Updated Script -- handler attempt for street number
Authored by: darrick on Jan 20, '05 08:10:23PM
i 'm trying to improve this super script a bit by trying to get the street number and name with this language


set savedTextItemDelimiters to AppleScript's text item delimiters
		try
			set street_address to (street of _address) as string
			set AppleScript's text item delimiters to {","}
			set number_and_street to first text item of street_address
			--reset the text item delimiters:
			set AppleScript's text item delimiters to savedTextItemDelimiters
		on error
			--also reset text item delimiters in case of an error:
			set AppleScript's text item delimiters to savedTextItemDelimiters
			beep
		end try
but i'm burned out and cannot get it to work (it should grab whatever comes before the first comma, which should be the street number and the street name before the apartment number or suite number)

[ Reply to This | # ]