Title: Re: Fixing busted threads?
On 11/1/04 8:04 PM, "Mike Dano" <[EMAIL PROTECTED]> wrote:

Thanks for your help Paul. I have the script up and running and it seems to be working well so far.

on run
   tell application "Microsoft Entourage"
        set currentMessages to the current messages
       repeat with theMsg in the currentMessages
           set theSubject to subject of theMsg
           if theSubject contains "Re:" then
               set sd to AppleScript's text item delimiters
               set AppleScript's text item delimiters to {"Re: "} -- or ("Re:"}
               set ls to text items of theSubject
               set AppleScript's text item delimiters to {""}
                set subject of theMsg to (ls as Unicode text)
                set AppleScript's text item delimiters to sd
           end if
       end repeat
   end tell
end
run

It slows you down to be resetting tids to sd every single repeat loop - and totally unnecessary. Aside from the fact that you should almost certainly leave them as {""} when you finish anyway, so this is just unnecessary fluff, if you insist on including it put the two sd lines outside the repeat loop, but inside the tell block. If there's any chance you might be running this on a large folder with a very large number of messages you'll speed it up a lot by  including 'my' in the repeat statement:

on run
   tell application "Microsoft Entourage"
        set sd to AppleScript's text item delimiters
       set currentMessages to the current messages
       repeat with theMsg in my currentMessages
           set theSubject to subject of theMsg
           if theSubject contains "Re:" then
               set AppleScript's text item delimiters to {"Re: "} -- or ("Re:"}
               set ls to text items of theSubject
               set AppleScript's text item delimiters to {""}
                set subject of theMsg to (ls as Unicode text)
            end if
       end repeat
       set AppleScript's text item delimiters to sd
   end tell
end
run    


But you don't need the sd lines at all. Always set tids before you coerce a list to text, in every script, and you'll be fine. Just in case someone forgot to, in another script, it's best to find that out. Or if you want to include a corrective to someone else's faulty script, then leave them at {""}, as I did - which I did on purpose.

--
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

PLEASE always state which version of Microsoft Office you are using - **2004**, X  or 2001. It's often impossible to answer your questions otherwise.

Reply via email to