Title: FW: New ROT13 Encode/Decode
Bryan Harris improved my ROT13 script as indicated below, allowing it to work on nearly any message. Thanks, Bryan! I did not have time to mess with it more.

He posted the following message to the OE Talk list; I'm forwarding to the Entourage list, since the identical script (apart from the name of the E-mail client program) works for either app.
--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984
My web page: <http://home.earthlink.net/~allenwatson/>

------ Forwarded Message
From: Bryan Harris <[EMAIL PROTECTED]>
Date: Fri, 27 Oct 2000 02:29:58 -0700
Subject: New ROT13 Encode/Decode



Here's a little update to Allen's ROT13 script.  This one's a lot more
liberal about when you can run it with no noticeable speed hit (130K of text
in less than 2 seconds on a 500MHz PB).  You can run it on most any single
message, open or closed, incoming, outgoing, or unsaved draft, in an open
window or not.  Only the selected text will be encoded/decoded, or if none,
the entire message will be processed.  Note that the script requires
requires Tanaka's OSAX, available from http://www.versiontracker.com/ or
http://www.osaxen.com/.

(Suggestions welcome, I'm far from being a software developer.)

Enjoy!

- Bryan




-- ROT13 Encode/Decode 2

-- Adapted from ROT13 Encode-Decode by Allen Watson, 10/25/2000
-- Adapted by Bryan Harris, 10/27/2000

-- requires Tanaka's OSAX, available from http://www.versiontracker.com/ or http://www.osaxen.com/


tell application "Outlook Express"
   
   set fromSet to characters of ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" & ¬
       "abcdefghijklmnopqrstuvwxyz")
   set toSet to characters of ("NOPQRSTUVWXYZABCDEFGHIJKLM" & ¬
       "nopqrstuvwxyzabcdefghijklm")
   
   if class of front window is draft window then save the front window
   
   set theMsgs to current messages
   
   if (count of theMsgs) is 0 then
        display dialog "Cannot find any text to encode/decode.  Select the message you wish to" & ¬
           "encode, or some text within an editable message." buttons {"Ok"} default button 1 with icon stop
       return
    end if
    
   set theMsg to item 1 of theMsgs
   
   set wholeMsg to false
   
   set theSel to selection
   
   if theSel is "" or (class of theSel � string) then
        set theSel to content of theMsg as string
       set wholeMsg to true
   end if
    
   set newSel to MT Swap characters theSel search list fromSet replace list toSet
   
   if wholeMsg then
        set content of theMsg to newSel
       if class of front window is draft window then -- draft windows don't update properly without closing and reopening
            set theBounds to bounds of front window
           close front window without saving
           open theMsg
           set bounds of front window to theBounds
       end if
    else
        try
            set selection to newSel
       on error
            if button returned of (display dialog "This is uneditable text. You can try selecting \"Edit Message\" from " & ¬
               "the Message menu, then running the script again, or simply click \"Place in new window\" to put the encoded " & ¬
               "text into a new draft window." buttons {"Place in new window", "Ok"} default button 2 with icon stop) ¬
               is "Place in new window" then
                make new draft window with properties {content:newSel}
           end if
            return
        end try
    end if
    
end tell



------ End of Forwarded Message

Reply via email to