Title: Re: script ideas -ALERT!
On 10/19/00 1:09 PM, "Paul Berkowitz" <[EMAIL PROTECTED]> wrote:

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

There was an error in there which could mss up other scripts. If you’ve already tried that script, then make this script and run it once from the Entourage script menu:

    set AppleScript’s text item delimiters to {""}


That’s it. i had just finished one for Title Case, which is very difficult and complicated. Then I crashed and lost everything. I’ll have to re-do it later. Rats.

Now here’s the fixed script:


----------------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 = "Selection" 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