Title: Re: script ideas -ALERT! - try this one
On 10/19/00 2:12 PM, I wrote:

>> ----------------SET DEFAULT POSTAL ADDRESS-----------------------
>
> There was an error in there which could mss up other scripts.

and another foolish error. This should work, but i have to go out now. I’ll be back later to check. Try it just with a few selected contacts. I also have the Title case script just about ready, but this time I’ll test it first.




 ----------------SET DEFAULT POSTAL ADDRESS-----------------------

on run
    
    tell application "Microsoft Entourage"
        
        display dialog "Would you like the" & return & return & "� Home postal address" & return & return & "� Work postal address" & return & return & "to be set as default postal address?" buttons {"Work", "Home"} with icon 1
        
        set whichAddress to button returned of result
        
        display dialog "And should this be applied to" & return & return & "� All contacts in the Address Book" & return & return & "� Contacts and/or contact members of Groups you have selected in the Address Book?" buttons {"Selected", "All"} with icon 1
        
        set howMany to button returned of result
        
        if howMany = "Selected" then
            
            try
                set theSelection to the selection -- if closed contact booklet in front, will error
                if (class of theSelection � list) or ({class of item 1 of theSelection} is not in {contact, group}) then error number -128 -- to enforce 'on error' if string, folder, address book, etc.
            on error
                
                beep
                display dialog "You need to select at least one contact in the Address Book first." with icon 0
                return
                
            end try
            
            
            set theList to {}
            
            repeat with theContact in theSelection
                if class of theContact = contact then -- avoid groups selected in error
                    set end of theList to theContact
                else if class of theContact = group then
                    repeat with grpMember in (every group entry of theContact)
                        set {dName, theAddress} to {display name, address} of content of grpMember
                        set grpContacts to find theAddress
                        if (count grpContacts) = 1 then
                            set grpContact to item 1 of grpContacts -- don't worry about display name, could be company, etc.
                        else if grpContacts � {} then
                            repeat with aContact in grpContacts
                                if dName = name of aContact then
                                    set grpContact to aContact
                                    exit repeat
                                else
                                    set grpContact to "" -- define
                                end if
                            end repeat
                        else -- if not a  Contact
                            set grpContact to "" -- define
                        end if
                        if grpContact � "" then set end of theList to grpContact
                    end repeat
                end if
            end repeat
            
        else -- all contacts
            
            set theList to every contact
            
        end if
        
        
        
        repeat with theContact in theList
            
            if whichAddress = "Home" then
                set thePostal to theContact's home address
                set def to home
                
            else
                set thePostal to theContact's business address
                set def to work
            end if
            
            if street address of thePostal � "" then
                set default postal address of theContact to def
            end if
            
        end repeat
        
        beep 2
        display dialog "All done!" with icon 1
        
    end tell
    
end run

-------------end script-------------------

--
Paul Berkowitz

Reply via email to