Title: Re: Dial phone script
On 10/20/00 1:56 PM, I wrote:

and, to be safe, all the lines that say

if homeNumber is not "" then set phoneList to phoneList & ("Home: " & homeNumber)
if workNumber is not "" then set phoneList to phoneList & ("Work: " & workNumber)

etc.

should really say

if homeNumber is not "" then set end of phoneList to phoneList & ("Home: " & homeNumber)
if workNumber is not "" then set end of phoneList to phoneList & ("Work: " & workNumber)

etc.

Nope: I got that wrong, (It’s easy to do!). It’s probably all right in the original, but what I meant to say was:


should really say

if homeNumber is not "" then set end of phoneList to  ("Home: " & homeNumber)
if workNumber is not "" then set end of phoneList to  ("Work: " & workNumber)

etc.

Apologies.

To make up, and with David’ permission, I’ve added a little section that will give your your own names for the Custom Phone fields, if you have any. So the whole script would be:


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

tell application "Acid Jazz" to Dial Phone theNumber





--
Paul Berkowitz

Reply via email to