Title: Re: ROT13 Encode/Decode
on 10/16/2000 2:08 PM, Bryan Harris at [EMAIL PROTECTED] wrote:

>
> Allen,
>
> The OE script doesn't seem to work, it just gives an error "Can't get char
> of ..." with the first few lines of the text of the message after that.

I enclose a much-improved version of the script. However, it REQUIRES "Tanaka's Osax 2.0", a scripting addition. I found that it near-instantly translated a message nearly 30K in length. I could not get plain applescript to do more than about 5000 characters without a stack overflow or "out of memory" error. I think you will find downloading the osax worthwhile. You can find it at Versiontracker.com, or at www.osaxen.com,

--- ROT13 Encode-Decode ---
--- Allen Watson, 10/25/2000 ---

--- Encode/Decode ROT13---
--- Allen Watson Mon, Oct 16, 2000 ---
on run
    if not CheckMessageWindow() then return
    EncodeDecode()
end run

on CheckMessageWindow()
    tell application "Microsoft Entourage"
        try
            set theMsg to displayed message of the front window
        on error
            save the front window
            set theMsg to displayed message of the front window
        end try
        if the class of theMsg is not outgoing message ¬
            and the class of theMsg is not incoming message then
            display dialog "This script is designed to work with an outgoing message window frontmost" buttons {"Okay"} default button "Okay" with icon stop
            return false
        end if
    end tell
    return true
end CheckMessageWindow

on EncodeDecode()
    set fromSet to characters of ("ABCDEFGHIJKLMNOPQRSTUVWXYZ" & ¬
        "abcdefghijklmnopqrstuvwxyz")
    set toSet to characters of ("NOPQRSTUVWXYZABCDEFGHIJKLM" & ¬
        "nopqrstuvwxyzabcdefghijklm")
    
    tell application "Microsoft Entourage"
        try
            set oldStr to selection
            if oldStr = "" then
                display dialog "Text to translate must be selected."
                return
            end if
            
            set newStr to MT Swap characters oldStr search list fromSet replace list toSet
            set selection to newStr
        on error theErr
            display dialog theErr
        end try
    end tell
end EncodeDecode
--- end of script ---

--
Peace,
Allen Watson <[EMAIL PROTECTED]> XNS name: =Allen Watson
A Mac family since 1984
My web page: <http://home.earthlink.net/~allenwatson/>

Reply via email to