I would like to update this script ( http://www.simondorfman.com/Programs/EntourageDialPhoneScript/ ) with this feature:
Instead of only working when a contact is selected in the contact window, it would also work if a message is selected and the from address is someone who is also in your contact list.
Anyone wanna give this a shot or give me some hints how I’d do it? I’ll give you credit in the updated script.
Thanks.
Here’s the current source:
-- This script is mostly the work of David Cortright. It was written for OS9. I updated it for OSX by using Abdialer (a $10 shareware app) instead of Acid Jazz (which is not available for OSX).
-- Get Abdialer here: http://www.macronsoft.com/pages/en/abdialer.html
-- I have made this script available here: http://www.SimonDorfman.com/Programs/EntourageDialPhoneScript/
-- January 25, 2004 Simon Dorfman http://www.SimonDorfman.com/
-- David's original copyright info is below.
-- Dial Phone 1.1
-- � David Cortright, 2000
-- <davecort@microsoft.com>
-- This script uses the application Acid Jazz to dial phone numbers for a selected contact in Entourage.
-- Select any one contact in a list view, then invoke this script.
-- If the selected contact has more than one number, you'll be asked to choose which one to dial.
-- Get Acid Jazz from here: <http://hotfiles.zdnet.com/cgi-bin/texis/swlib/mac/infomac.html?fcode=MC10904>
-- Acid Jazz is shareware ($15).
-- Minor modifications by Matt Ridley <scripts@mattridley.com>.
-- More modifications and enhancements by Paul Berkowitz <berkowit@silcom.com>.
set phoneList to {}
set errString to "This script only works with one contact selected in a list view."
tell application "Microsoft Entourage"
try
set s to the selection
set t to item 1 of s
if the class of t is contact then set theContact to t
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
set custList to address book 1's {custom phone number one name, custom phone number two name, custom phone number three name, custom phone number four name}
repeat with i from 1 to 4
set x to item i of custList
if x ends with ":" then set x to text 1 thru -2 of x
set item i of custList to x
end repeat
set {custName1, custName2, custName3, custName4} to custList
try
set homeNumber to home phone number of theContact
set workNumber to business phone number of theContact
set otherHomeNumber to other home phone number of theContact
set otherWorkNumber to other business phone number of theContact
set mobileNumber to mobile phone number of theContact
set mainNumber to main phone number of theContact
set assistantNumber to assistant phone number of theContact
set pagerNumber to pager phone number of theContact
set homeFaxNumber to home fax phone number of theContact
set workFaxNumber to business fax phone number of theContact
set custom1 to custom phone number one of theContact
set custom2 to custom phone number two of theContact
set custom3 to custom phone number three of theContact
set custom4 to custom phone number four of theContact
if homeNumber is not "" then set end of phoneList to ("Home: " & homeNumber)
if workNumber is not "" then set end of phoneList to ("Work: " & workNumber)
if otherHomeNumber is not "" then set end of phoneList to ("Home 2: " & otherHomeNumber)
if otherWorkNumber is not "" then set end of phoneList to ("Work 2: " & otherWorkNumber)
if mobileNumber is not "" then set end of phoneList to ("Mobile: " & mobileNumber)
if mainNumber is not "" then set end of phoneList to ("Main: " & mainNumber)
if assistantNumber is not "" then set end of phoneList to ("Assistant: " & assistantNumber)
if pagerNumber is not "" then set end of phoneList to ("Pager: " & pagerNumber)
if homeFaxNumber is not "" then set end of phoneList to ("Home Fax: " & homeFaxNumber)
if workFaxNumber is not "" then set end of phoneList to ("Work Fax: " & workFaxNumber)
if custom1 is not "" then set end of phoneList to (custName1 & ": " & custom1)
if custom2 is not "" then set end of phoneList to (custName2 & ": " & custom2)
if custom3 is not "" then set end of phoneList to (custName3 & ": " & custom3)
if custom4 is not "" then set end of phoneList to (custName4 & ": " & custom4)
set theName to name of theContact
if theName = "" then set theName to company of theContact
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
end tell
if (count of phoneList) = 1 then
set theResult to phoneList
else
if (count of phoneList) is greater than 1 then
try
set theResult to choose from list phoneList with prompt "Choose a phone number to dial for " & theName & �
":" default items {(item 1 of phoneList)} without multiple selections allowed and empty selection allowed
on error
display dialog "This script requires a scripting addition that is not installed on your computer. " & �
"You must have OS 8.5 or greater in order to use this script." with icon 1 buttons {"OK"} default button "OK"
end try
else
display dialog "That contact has no phone numbers." with icon note buttons {"OK"} default button "OK"
return
end if
end if
if theResult = {} or theResult is false then return
set t to item 1 of theResult
set i to offset of ": " in t
set theNumber to text (i + 2) thru -1 of t
try
if theNumber is not "" then
tell application "ABDialer"
dial theNumber
end tell
end if
on error
display dialog "There was an error dialing the selection." buttons {"OK"}
end try
First, you could take a look at my script, Dial Number for searching the Address Book.app and cleaning a number for dialing. To search the contact list in MS Entourage, here are someescript://com.apple.scripteditor/?action=new&script=–the_contact%20can%20be%20a%20name%20or%20an%20email%20address%0A–to%20get%20the%20email%20address%20from%20the%20current%20selection%3A%0Aset%20the_contact%20to%20(my%20get_email_address_from_cur_message())%0Aif%20class%20of%20the_contact%20%3D%20string%20then%0A%09beep%0A%09display%20dialog%20the_contact%20buttons%20%7B%22OK%22%7D%20default%20button%201%20with%20icon%200%20giving%20up%20after%2010%0Aelse%0A%09set%20contact_list%20to%20(my%20get_contacts_numbers(the_contact%20as%20string))%0A%09if%20class%20of%20contact_list%20%3D%20string%20then%0A%09%09beep%0A%09%09display%20dialog%20contact_list%20buttons%20%7B%22OK%22%7D%20default%20button%201%20with%20icon%200%20giving%20up%20after%2010%0A%09else%0A%09%09set%20the_number%20to%20(choose%20from%20list%20contact_list%20with%20prompt%20%22Which%20number%20should%20I%20dial%3F%22)%20as%20string%0A%09%09if%20the_number%20%3D%20%22false%22%20then%20return%0A%09%09–dial%20the_number%20here%0A%09%09return%20the_number%0A%09end%20if%0Aend%20if%0A%0Aon%20get_email_address_from_cur_message()%0A%09tell%20application%20%22Microsoft%20Entourage%22%0A%09%09set%20the_item%20to%20item%201%20of%20(get%20selection)%0A%09%09if%20class%20of%20the_item%20is%20in%20%7Bincoming%20message,%20outgoing%20message%7D%20then%0A%09%09%09set%20the_addresses%20to%20(my%20extract_addresses(headers%20of%20the_item))%0A%09%09%09if%20the_addresses%20%3D%20%7B%7D%20then%0A%09%09%09%09return%20%22No%20addresses%20found%20in%20the%20selected%20message.%22%0A%09%09%09else%20if%20(count%20of%20the_addresses)%20%3D%201%20then%0A%09%09%09%09return%20the_addresses%0A%09%09%09else%0A%09%09%09%09tell%20me%20to%20set%20this_address%20to%20(choose%20from%20list%20the_addresses%20with%20prompt%20%22Multiple%20addresses%20were%20found.%20Use%3A%22)%0A%09%09%09%09if%20this_address%20%3D%20false%20then%20return%20%22User%20canceled.%22%0A%09%09%09%09return%20this_address%0A%09%09%09end%20if%0A%09%09else%0A%09%09%09return%20%22Selection%20is%20not%20a%20message.%20Please%20try%20again.%22%0A%09%09end%20if%0A%09end%20tell%0Aend%20get_email_address_from_cur_message%0A%0Aon%20extract_addresses(the_text)%0A%09set%20%7Bthe_text,%20address_list%7D%20to%20%7Bwords%20of%20the_text,%20%7B%7D%7D%0A%09repeat%20with%20i%20from%202%20to%20(count%20of%20the_text)%0A%09%09try%0A%09%09%09if%20item%20i%20of%20the_text%20%3D%20%22%40%22%20then%0A%09%09%09%09set%20temp_address%20to%20((item%20(i%20-%201)%20of%20the_text)%20%26%20(item%20i%20of%20the_text)%20%26%20(item%20(i%20+%201)%20of%20the_text))%20as%20string%0A%09%09%09%09if%20temp_address%20is%20not%20in%20address_list%20then%0A%09%09%09%09%09if%20(my%20verify_address(temp_address))%20then%20set%20end%20of%20address_list%20to%20temp_address%0A%09%09%09%09end%20if%0A%09%09%09end%20if%0A%09%09end%20try%0A%09end%20repeat%0A%09return%20address_list%0Aend%20extract_addresses%0A%0Aon%20verify_address(temp_address)%0A%09set%20address_parts%20to%20(text%20items%20of%20temp_address)%0A%09if%20(count%20of%20address_parts)%20%3C%202%20then%20return%20false%0A%09set%20AppleScript’s%20text%20item%20delimiters%20to%20%22.%22%0A%09set%20address_parts%20to%20text%20items%20of%20temp_address%0A%09set%20AppleScript’s%20text%20item%20delimiters%20to%20%22%22%0A%09if%20(count%20of%20address_parts)%20%3C%202%20or%20(count%20of%20item%20-1%20of%20address_parts)%20%3E%204%20then%20return%20false%0A%09return%20true%0Aend%20verify_address%0A%0Aon%20get_contacts_numbers(the_contact)%0A%09tell%20application%20%22Microsoft%20Entourage%22%0A%09%09set%20return_data%20to%20%7B%7D%0A%09%09set%20the_indent%20to%20%22%20%20%20%20%22%0A%09%09repeat%20with%20i%20from%201%20to%20count%20of%20contacts%0A%09%09%09tell%20contact%20i%0A%09%09%09%09set%20use_contact%20to%20false%0A%09%09%09%09if%20the_contact%20contains%20%22%40%22%20then%0A%09%09%09%09%09–if%20it’s%20an%20email,%20lets%20get%20everything%20at%20once%3A%0A%09%09%09%09%09if%20vcard%20data%20contains%20the_contact%20then%20set%20use_contact%20to%20true%0A%09%09%09%09else%0A%09%09%09%09%09–otherwise%20let’s%20assume%20it’s%20a%20name%3A%0A%09%09%09%09%09if%20((first%20name%20as%20string)%20%26%20%22%20%22%20%26%20(last%20name%20as%20string))%20contains%20the_contact%20then%20set%20use_contact%20to%20true%0A%09%09%09%09end%20if%0A%09%09%09%09if%20use_contact%20%3D%20true%20then%0A%09%09%09%09%09set%20this_data%20to%20%7B%7D%0A%09%09%09%09%09if%20home%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Home%20(voice)%3A%20%22%20%26%20((home%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20other%20home%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Home%20(other)%3A%20%22%20%26%20((other%20home%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20home%20fax%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Home%20(fax)%3A%20%22%20%26%20((home%20fax%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20business%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Business%20(voice)%3A%20%22%20%26%20((business%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20other%20business%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Business%20(other)%3A%20%22%20%26%20((other%20business%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20business%20fax%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Business%20(fax)%3A%20%22%20%26%20((business%20fax%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20pager%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Pager%3A%20%22%20%26%20((pager%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20mobile%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Mobile%3A%20%22%20%26%20((mobile%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20main%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Main%3A%20%22%20%26%20((main%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20assistant%20phone%20number%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Assistant%3A%20%22%20%26%20((assistant%20phone%20number)%20as%20string))%0A%09%09%09%09%09if%20custom%20phone%20number%20one%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Custom%3A%20%22%20%26%20((custom%20phone%20number%20one)%20as%20string))%0A%09%09%09%09%09if%20custom%20phone%20number%20two%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Custom%3A%20%22%20%26%20((custom%20phone%20number%20two)%20as%20string))%0A%09%09%09%09%09if%20custom%20phone%20number%20three%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Custom%3A%20%22%20%26%20((custom%20phone%20number%20three)%20as%20string))%0A%09%09%09%09%09if%20custom%20phone%20number%20four%20%AD%20%22%22%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22Custom%3A%20%22%20%26%20((custom%20phone%20number%20four)%20as%20string))%0A%09%09%09%09%09if%20this_data%20%3D%20%7B%7D%20then%20set%20end%20of%20this_data%20to%20(the_indent%20%26%20%22No%20numbers%20found.%22)%0A%09%09%09%09%09set%20beginning%20of%20this_data%20to%20((first%20name%20as%20string)%20%26%20%22%20%22%20%26%20(last%20name%20as%20string)%20%26%20%22%3A%22)%0A%09%09%09%09%09set%20return_data%20to%20return_data%20%26%20this_data%0A%09%09%09%09end%20if%0A%09%09%09end%20tell%0A%09%09end%20repeat%0A%09end%20tell%0A%09if%20return_data%20%3D%20%7B%7D%20then%20set%20return_data%20to%20%22No%20matching%20contacts%20found.%22%0A%09return%20return_data%0Aend%20get_contacts_numbers]Open this script in a new Script Editor window[/url].
–the_contact can be a name or an email address
–to get the email address from the current selection:
set the_contact to (my get_email_address_from_cur_message())
if class of the_contact = string then
beep
display dialog the_contact buttons {“OK”} default button 1 with icon 0 giving up after 10
else
set contact_list to (my get_contacts_numbers(the_contact as string))
if class of contact_list = string then
beep
display dialog contact_list buttons {“OK”} default button 1 with icon 0 giving up after 10
else
set the_number to (choose from list contact_list with prompt “Which number should I dial?”) as string
if the_number = “false” then return
–dial the_number here
return the_number
end if
end if
on get_email_address_from_cur_message()
tell application “Microsoft Entourage”
set the_item to item 1 of (get selection)
if class of the_item is in {incoming message, outgoing message} then
set the_addresses to (my extract_addresses(headers of the_item))
if the_addresses = {} then
return “No addresses found in the selected message.”
else if (count of the_addresses) = 1 then
return the_addresses
else
tell me to set this_address to (choose from list the_addresses with prompt “Multiple addresses were found. Use:”)
if this_address = false then return “User canceled.”
return this_address
end if
else
return “Selection is not a message. Please try again.”
end if
end tell
end get_email_address_from_cur_message
on extract_addresses(the_text)
set {the_text, address_list} to {words of the_text, {}}
repeat with i from 2 to (count of the_text)
try
if item i of the_text = “@” then
set temp_address to ((item (i - 1) of the_text) & (item i of the_text) & (item (i + 1) of the_text)) as string
if temp_address is not in address_list then
if (my verify_address(temp_address)) then set end of address_list to temp_address
end if
end if
end try
end repeat
return address_list
end extract_addresses
on verify_address(temp_address)
set address_parts to (text items of temp_address)
if (count of address_parts) < 2 then return false
set AppleScript’s text item delimiters to “.”
set address_parts to text items of temp_address
set AppleScript’s text item delimiters to “”
if (count of address_parts) < 2 or (count of item -1 of address_parts) > 4 then return false
return true
end verify_address
on get_contacts_numbers(the_contact)
tell application “Microsoft Entourage”
set return_data to {}
set the_indent to " "
repeat with i from 1 to count of contacts
tell contact i
set use_contact to false
if the_contact contains “@” then
–if it’s an email, lets get everything at once:
if vcard data contains the_contact then set use_contact to true
else
–otherwise let’s assume it’s a name:
if ((first name as string) & " " & (last name as string)) contains the_contact then set use_contact to true
end if
if use_contact = true then
set this_data to {}
if home phone number is not “” then set end of this_data to (the_indent & "Home (voice): " & ((home phone number) as string))
if other home phone number is not “” then set end of this_data to (the_indent & "Home (other): " & ((other home phone number) as string))
if home fax phone number is not “” then set end of this_data to (the_indent & "Home (fax): " & ((home fax phone number) as string))
if business phone number is not “” then set end of this_data to (the_indent & "Business (voice): " & ((business phone number) as string))
if other business phone number is not “” then set end of this_data to (the_indent & "Business (other): " & ((other business phone number) as string))
if business fax phone number is not “” then set end of this_data to (the_indent & "Business (fax): " & ((business fax phone number) as string))
if pager phone number is not “” then set end of this_data to (the_indent & "Pager: " & ((pager phone number) as string))
if mobile phone number is not “” then set end of this_data to (the_indent & "Mobile: " & ((mobile phone number) as string))
if main phone number is not “” then set end of this_data to (the_indent & "Main: " & ((main phone number) as string))
if assistant phone number is not “” then set end of this_data to (the_indent & "Assistant: " & ((assistant phone number) as string))
if custom phone number one is not “” then set end of this_data to (the_indent & "Custom: " & ((custom phone number one) as string))
if custom phone number two is not “” then set end of this_data to (the_indent & "Custom: " & ((custom phone number two) as string))
if custom phone number three is not “” then set end of this_data to (the_indent & "Custom: " & ((custom phone number three) as string))
if custom phone number four is not “” then set end of this_data to (the_indent & "Custom: " & ((custom phone number four) as string))
if this_data = {} then set end of this_data to (the_indent & “No numbers found.”)
set beginning of this_data to ((first name as string) & " " & (last name as string) & “:”)
set return_data to return_data & this_data
end if
end tell
end repeat
end tell
if return_data = {} then set return_data to “No matching contacts found.”
return return_data
end get_contacts_numbers
Note that you could use “my get_contacts_numbers(the_contact)” for either a name or an email address and that you could just search your contacts with user input like so:
set the_contact to text returned of (display dialog "Enter a name or email addres for which I should search:" default answer "" buttons {"Search"} default button 1 with icon 1)
set contact_list to (my get_contacts_numbers(the_contact))
set the_number to (choose from list contact_list with prompt "Which number should I dial?") as string
Simon, here is your script, modified so that the user can (a) select an entry in the main Address Book, (b) have an open contact, or (c) have an open incoming message, in which case it looks up the sender’s record in the Entourage Address Book using the e-mail address; if more than one contact is found it will let the user select which contact to use. The rest of the script, from the point that “theContact” is defined, is unchanged from your version.
-- This script is mostly the work of David Cortright.� It was written for OS9.� I updated it for OSX by using Abdialer (a $10 shareware app) instead of Acid Jazz (which is not available for OSX).
-- Get Abdialer here: http://www.macronsoft.com/pages/en/abdialer.html
-- I have made this script available here:� http://www.SimonDorfman.com/Programs/EntourageDialPhoneScript/
-- January 25, 2004� �Simon Dorfman� http://www.SimonDorfman.com/
-- David's original copyright info is below.
-- Dial Phone 1.1
-- � David Cortright, 2000
-- <davecort@microsoft.com>
-- This script uses the application Acid Jazz to dial phone numbers for a selected contact in Entourage.
-- Select any one contact in a list view, then invoke this script.
-- If the selected contact has more than one number, you'll be asked to choose which one to dial.
-- Get Acid Jazz from here: <http://hotfiles.zdnet.com/cgi-bin/texis/swlib/mac/infomac.html?fcode=MC10904>
-- Acid Jazz is shareware ($15).
-- Minor modifications by Matt Ridley <scripts@mattridley.com>.
-- More modifications and enhancements by Paul Berkowitz <berkowit@silcom.com>.
set phoneList to {}
set errString to "Error trying to determine contact. Please select a contact or an incoming message."
tell application "Microsoft Entourage"
try
set f to displayed feature of the front window
if f is address book 1 then
set s to the selection
set t to item 1 of s
if the class of t is contact then
set theContact to t
else
display dialog "Please select a contact."
end if
else if the class of f is incoming message then
set theSender to address of the sender of f
try
set theContact to find theSender -- Is sender in address book?
if (count theContact) > 1 then
display dialog "You have more than one contact with this e-mail address. Please select the desired contact in the next dialog."
set namelist to {}
repeat with aContact in theContact
copy name of aContact to the end of namelist
end repeat
set theName to choose from list namelist with prompt "Choose desired contact." without multiple selections allowed
set theName to item 1 of theName
set theContact to contact theName
end if
on error theErr
display dialog "The sender is not in your address book, sorry!" & return & theErr
return
end try
else if the class of f is contact then
set theContact to f
else
display dialog "Unable to determine contact to dial up."
end if
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
set custList to address book 1's {custom phone number one name, custom phone number two name, custom phone number three name, custom phone number four name}
repeat with i from 1 to 4
set x to item i of custList
if x ends with ":" then set x to text 1 thru -2 of x
set item i of custList to x
end repeat
set {custName1, custName2, custName3, custName4} to custList
try
set homeNumber to home phone number of theContact
set workNumber to business phone number of theContact
set otherHomeNumber to other home phone number of theContact
set otherWorkNumber to other business phone number of theContact
set mobileNumber to mobile phone number of theContact
set mainNumber to main phone number of theContact
set assistantNumber to assistant phone number of theContact
set pagerNumber to pager phone number of theContact
set homeFaxNumber to home fax phone number of theContact
set workFaxNumber to business fax phone number of theContact
set custom1 to custom phone number one of theContact
set custom2 to custom phone number two of theContact
set custom3 to custom phone number three of theContact
set custom4 to custom phone number four of theContact
if homeNumber is not "" then set end of phoneList to ("Home: " & homeNumber)
if workNumber is not "" then set end of phoneList to ("Work: " & workNumber)
if otherHomeNumber is not "" then set end of phoneList to ("Home 2: " & otherHomeNumber)
if otherWorkNumber is not "" then set end of phoneList to ("Work 2: " & otherWorkNumber)
if mobileNumber is not "" then set end of phoneList to ("Mobile: " & mobileNumber)
if mainNumber is not "" then set end of phoneList to ("Main: " & mainNumber)
if assistantNumber is not "" then set end of phoneList to ("Assistant: " & assistantNumber)
if pagerNumber is not "" then set end of phoneList to ("Pager: " & pagerNumber)
if homeFaxNumber is not "" then set end of phoneList to ("Home Fax: " & homeFaxNumber)
if workFaxNumber is not "" then set end of phoneList to ("Work Fax: " & workFaxNumber)
if custom1 is not "" then set end of phoneList to (custName1 & ": " & custom1)
if custom2 is not "" then set end of phoneList to (custName2 & ": " & custom2)
if custom3 is not "" then set end of phoneList to (custName3 & ": " & custom3)
if custom4 is not "" then set end of phoneList to (custName4 & ": " & custom4)
set theName to name of theContact
if theName = "" then set theName to company of theContact
on error theErr
display dialog theErr & return & return & errString with icon 1 buttons {"OK"} default button "OK"
return
end try
end tell
if (count of phoneList) = 1 then
set theResult to phoneList
else
if (count of phoneList) is greater than 1 then
try
set theResult to choose from list phoneList with prompt "Choose a phone number to dial for " & theName & �
":" default items {(item 1 of phoneList)} without multiple selections allowed and empty selection allowed
on error
display dialog "This script requires a scripting addition that is not installed on your computer. " & �
"You must have OS 8.5 or greater in order to use this script." with icon 1 buttons {"OK"} default button "OK"
end try
else
display dialog "That contact has no phone numbers." with icon note buttons {"OK"} default button "OK"
return
end if
end if
if theResult = {} or theResult is false then return
set t to item 1 of theResult
set i to offset of ": " in t
set theNumber to text (i + 2) thru -1 of t
try
if theNumber is not "" then
tell application "ABDialer"
dial theNumber
end tell
end if
on error
display dialog "There was an error dialing the selection." buttons {"OK"}
end try