Title: Re: Remove Double spaces
On 12/1/04 6:41 PM, "Mark Falchook" <[EMAIL PROTECTED]> wrote:

> Re: Double Spaces
>
> It would be great if someone could post the entire corrected script after
> they can confirm that it definitely works...
>
> Thanks,
> -Mark
>
I'm not sure anyone ever posted the corrected script, so--here is the script that works on saved messages. If you have a draft window you want to process, you could

  1. Save the message.
  2. Run the script.
  3. Close the window, and re-open it from the Drafts folder.

If you do steps 1 and 2, the visible window will not reflect the changes, and if you edit further and save, you will write over the changes. That's why step 3 is required. The script could be enhanced to do all that, of course. It could test if the visible window is a draft window and if so, save the window, do its thing, then get the message id (displayed content of the front window, after saving), close the window and re-open the message. I think it's just as easy to remember to save it if it is a draft.

-- Script "Collapse_space_runs" by Allen Watson
tell application "Microsoft Entourage"
 -- get the currently selected message or messages
 set selectedMessages to current messages
 -- if there are no messages selected, warn the user and then quit
 if selectedMessages is {} then
 display dialog "Please select a message first and then run this script." with icon 1
 return
 end if
 repeat with theMessage in selectedMessages
 -- get message's content into a variable
 set thecontent to content of theMessage
 -- collapse space runs
 set oldDelims to AppleScript's text item delimiters
 repeat while thecontent contains " "
 set AppleScript's text item delimiters to {" "} -- Two spaces
 set thecontent to text items of thecontent
 set AppleScript's text item delimiters to {" "} -- One space
 set thecontent to thecontent as text
 set AppleScript's text item delimiters to oldDelims
 end repeat
 set the content of theMessage to thecontent
 end repeat
end tell

Reply via email to