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

Canadian phone number lookup scripts for Address Book Apps
The address book scripts on the site gave me some ideas useful for simple Canadian lookups using Canada411.com. There are three scripts: I'd like to credit the other people who submitted code for previous lookup scripts to this site, I've borrowed liberally. Any coding sloppiness is mine, I have no scripting experience. Suggestions for improvement appreciated.

[robg adds: To use the scripts, simply cut and paste the text below into a blank Script Editor document and save as a script in the ~/Library -> Address Book Plug-Ins directory. Then quit Address Book if it is open and relaunch it.]
    •    
  • Currently 1.00 / 5
  • 1
  • 2
  • 3
  • 4
  • 5
  (1 vote cast)
 
[11,870 views]  

Canadian phone number lookup scripts for Address Book | 6 comments | Create New Account
Click here to return to the 'Canadian phone number lookup scripts for Address Book' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Canadian phone number lookup scripts for Address Book
Authored by: lanej0 on Feb 21, '05 11:10:11AM

Maybe I'm just blind, but how do you use these after you've saved them? I put them in the plug-ins folder, but I can't figure out how to access them in Address Book.



[ Reply to This | # ]
Canadian phone number lookup scripts for Address Book
Authored by: andrejbl on Feb 21, '05 11:43:28AM
Maybe I'm just blind, but how do you use these after you've saved them? I put them in the plug-ins folder, but I can't figure out how to access them in Address Book.
Right-click or Ctrl-click on an address to access the script "Look up Personal Phone Number".

Similarly, right-click or Ctrl-click on a phone number to access the script "Look up Address from Phone Number".

Andre

---
Lowering entropy one day at a time.

[ Reply to This | # ]

Belgian number lookup scripts for Address Book
Authored by: dotK on Feb 21, '05 01:48:47PM

I took the liberty to modify the script to the Belgian phonedirectory.

Does anyone know how to strip the +32 from my addressbook and change it into a 0?

The site doesn't like the +32 ;)

---
Switched



[ Reply to This | # ]
Belgian number lookup scripts for Address Book
Authored by: zoff on Feb 21, '05 10:15:42PM

try something like this:

set the_number to "+32456789"--
set y to items 4 thru (count items of the_number) of the_number as string--
set new_number to "0" & y--

Watch out for line breaks, I've added -- at the end of each line.



[ Reply to This | # ]
Modification: use default browser, merge address lookup scripts
Authored by: bhorrock on Feb 22, '05 01:23:19PM
Here is a modification that merges the personal and business scripts into one script.
Features:
  • 'work' addresses use the business lookup
  • 'home' and 'other' use the personal lookup
  • Supports both French and English labels
  • Uses the default browser
  • Bug fixing to handle some missing values

using terms from application "Address Book"
	on action property
		return "address"
	end action property
	
	on action title for aPerson with aaddress
		return "Canada 411 Lookup"
	end action title
	
	on should enable action for aPerson with aaddress
        return true
	end should enable action
	
	on perform action for aPerson with aaddress
	   (* set "as string" so we don't leave references to missing values hanging *)
		 set cit to city of aaddress        as string
		 set org to organization of aPerson as string
         set prov to state of aaddress      as string
         set ln to last name of aPerson     as string
         set fn to first name of aPerson    as string 

                    
        set def_browser to displayed name of (info for alias getDefaultBrowser())  
      (*  display dialog "default browser: " & def_browser *)

        
        (* What type of address *)
        set atype to label of aaddress

        if atype is "work" or "travail" then
            set query to "http://canada411.yellowpages.ca/searchBusiness.do?srchtype=business&sType=simpleSearch&action=homeSearch&step=getDirectory&Se=smp"
            if org is missing value then 
                set query to my queryWithParam(query, "what", ln)
            else
                set query to my queryWithParam(query, "what", org)
            end if
            
            set query to my queryWithParam(query, "city", cit)
        else
            set query to "http://findaperson.canada411.ca/search/Find_Person?"
            set query to my queryWithParam(query, "firstname", fn)
            set query to my queryWithParam(query, "name", ln)
            set query to my queryWithParam(query, "city_zip", cit)
            set query to my queryWithParam(query, "state_id", prov)             
        end if

        
		set AppleScript's text item delimiters to ""
		tell application def_browser
			activate
			open location (query)
		end tell
	end perform action
	
	
    on getDefaultBrowser()
       set creatorType to word -1 of (do shell script  "defaults read com.apple.LaunchServices |grep -C5 U:http | grep -w LSBundleSignature")
       set {text:creatorType} to (text of creatorType) as text
       tell application "Finder"
          set {defBrowserName, browserContainerAlias} to {name, container} of application file id creatorType
       end tell
       return (browserContainerAlias as text) & defBrowserName
    end getDefaultBrowser

    on queryWithParam(query, param, val)    
        if (val = "missing value" ) or (param is missing value ) then
            return query
        end if
        if query ends with "?" or "&" then
            set retval to query & param & "=" & val
        else
            set retval to query & "&" & param & "=" & val
        end if
        return retval
    end queryWithParam

end using terms from




[ Reply to This | # ]
Modification: use default browser, merge address lookup scripts
Authored by: miles_thatsme on Feb 23, '05 12:41:13AM

Awesome! Much better. Thanks very much.



[ Reply to This | # ]