Re: I betray my ignorance ... too
Re: I betray my ignorance ... too
- Subject: Re: I betray my ignorance ... too
- From: Paul Berkowitz <email@hidden>
- Date: Tue, 11 Sep 2001 00:38:28 -0700
On 9/11/01 12:01 AM, "Bernard Azancot" <email@hidden> wrote:
>
I would like to write a MOE script (vanilla would be best) that would
>
perform a search-replace on recieved messages.
>
>
In other words, how would you replace all CR abd TAB by spaces, in a string
>
?
>
Use text item delimiters. BTW, I think you may find that tabs aren't
actually tabs, but have replaced by 4 spaces. And in case you want to
preserve paragraphs, I've added that in.
You will also need a routine for removing > and >> and >>> signs from quoted
lines. If you're removing hardwrapping, you will want to remove those from
all lines except the first in each paragraph, or it will look an unholy
mess. But you'll get an idea of the technique from what follows. In
applescript, "lines" are 'paragraphs', so before you remove the CRs you may
want to check in a big repeat loop for all lines with >. it's quite
complicated to figure out how to preserve only the ones starting real
paragraphs - I leave that to you if it matters to you.
And I really use option-7 for the placeholder, but that would be mangled by
the list server.
tell application "Outlook Express"
set theMsg to item 1 of (get current messages) -- or a repeat loop
through all
set theContent to content of theMsg
end tell
--remove > signs
set newContent to ""
repeat with i from 1 to (count paragraphs of theContent)
set theLine to paragraph i of theContent
repeat while theLine starts with ">"
set theLine to text 2 thru -1 of theLine
end repeat
set newContent to newContent & return & theLine
end repeat
set theContent to newContent
--preserve paragraphs? next 4 lines optional
set AppleScript's text item delimiters to {return & return}
set ls to text items of theContent
set AppleScript's text item delimiters to {"@@@@@"} -- placeholder
set theContent to ls as string
set AppleScript's text item delimiters to {return}
set ls to text items of theContent
set AppleScript's text item delimiters to {space}
set theContent to ls as string
set AppleScript's text item delimiters to {tab}
set ls to text items of theContent
set AppleScript's text item delimiters to {space} -- placeholder
set theContent to ls as string
--I think tabs are replaced in OE by 4 spaces, so the above won't do
anything, try this:
set AppleScript's text item delimiters to {" "} -- 4 spaces
set ls to text items of theContent
set AppleScript's text item delimiters to {space} -- placeholder
set theContent to ls as string
--remove placeholder , optional
set AppleScript's text item delimiters to {"@@@@@"}
set ls to text items of theContent
set AppleScript's text item delimiters to {return & return}
set theContent to ls as string
set AppleScript's text item delimiters to {""} -- default
tell application "Outlook Express"
set content of theMsg to theContent
end tell
--
Paul Berkowitz