on 20/9/01 4:52 AM, Allen Watson at [EMAIL PROTECTED] wrote:

> On or near 9/17/01 10:22 PM, David Leitch at [EMAIL PROTECTED]
> observed:
> 
>> A few weeks ago I posted a very similar to the one below. Allen Watson very
>> kindly sent in a modified version of this script however I am still
>> receiving errors (Entourage can't continue Myreplace), any further
>> suggestions would be appreciated.
> 
> That "cannot continue" message often indicates an error in the subroutine,
> or else in the calling sequence. If the line invoking MyReplace starts
> something like this:
> 
> Set x to MyReplace(...
> 
> try changing it by inserting the word "my" in front of the subroutine name:
> 
> Set x to my MyReplace(...
> 
> I know that makes for terrible reading (my my!), but it may fix the problem.
> On the other hand, if the word "my" is already there, try taking it OUT.
> 
> If that does not fix the problem, let me know. However, I'm pretty sure that
> the code in the subroutine has been tested enough to be free of errors, so
> it is probably in the calling sequence.

Adding an extra my in front of all the mybefore, myreplace and myafter
routines now has the script working most of the time.

However I am still getting errors from internal JPMorgan lotus notes
addresses of the form:

                    Peter C
                    Talbot               To:     Brian D
                                         Johnson/JPMCHASE@CHASE

This a message from Peter Talbot. The script is returning the error message
:Could not parse sender's address.

The reason the script is doing this is because the addressor is sending from
our local Sydney Office and the Notes form generating the sender doesn't
include an @ in the sender address under such circumstances.

For perfection (and my purposes) if the script encounters an address of that
form it would ideally set the sender to

[EMAIL PROTECTED]

However I could live with Peter C Talbot and I would manually fill in the
missing bits.

I appreciate this script is of no use to anyone else on this list. I also
appreciate that even if I could write such a script (and I used to be able
to program quite competently even in 6502 assembler) it would take a
considerable learning curve. Just the same to make it work is a great
pleasure and I want to express again my gratitude to Paul and Allen for
helping me keep Entourage a practical solution in this Lotus Notes dominated
institution.

The script at present is:
ell application "Microsoft Entourage"
    set theMsg to item 1 of (get current messages)
    if address of sender of theMsg is "[EMAIL PROTECTED]" then
        set theContent to content of theMsg
        -- Remove leading blanks
        -- Collapse space runs to single space
        set paras to paragraphs of theContent
        set newstuff to ""
        repeat with aLine in paras
            repeat while aLine begins with " "
                if aLine is not " " then
                    set aLine to text 2 thru -1 of aLine
                else
                    set aLine to ""
                end if
            end repeat
            repeat while aLine contains "  "
                set aLine to my myReplace("  ", " ", aLine)
            end repeat
            if length of aLine > 0 then set newstuff to newstuff & aLine &
return
        end repeat
        if ((words 1 thru 3 of newstuff) as text) contains "attachment" then
            set newstuff to my myAfter(")", newstuff) -- Discard the
attachment info
        end if
        
        set trialAddress to word 1 of newstuff
        if trialAddress contains "@" then
            set finalAddress to trialAddress -- We are done
            return finalAddress
        else
            set trialAddress to my myBefore("To:", newstuff)
            set trialAddress to my myReplace(return, "", trialAddress)
            if trialAddress does not contain "@" then
                set part2 to my myBetween("<", ">", newstuff)
                set part2 to "<" & my myBefore(" ", part2) & my
myAfter(return, part2) & ">"
                set trialAddress to trialAddress & " " & part2
            end if
            set finalAddress to trialAddress
        end if
        set nameLine to finalAddress
        if nameLine does not contain "@" then
            display dialog "Could not parse sender's address"
            return
        else
            if nameLine does not contain " " then
                set dName to ""
                set eAddress to nameLine
            else
                set dName to my myBefore("<", nameLine)
                set eAddress to my myBetween("<", ">", nameLine)
            end if
            set AppleScript's text item delimiters to {""}
            set display name of sender of theMsg to dName
            set address of sender of theMsg to eAddress
            --exit repeat
        end if
    end if
end tell


on myReplace(oldS, newS, theText)
    set od to AppleScript's text item delimiters
    set AppleScript's text item delimiters to oldS
    set temp to text items of theText
    set AppleScript's text item delimiters to newS
    set theText to temp as text
    return theText
end myReplace

to myBetween(firstPart, secondPart, someString)
    set lastpart to myAfter(firstPart, someString) -- What follows firstPart
    set midpart to myBefore(secondPart, lastpart)
    return midpart
end myBetween

to myBefore(subStr, mainStr)
    set od to AppleScript's text item delimiters
    set AppleScript's text item delimiters to subStr
    set temp to text items of mainStr
    set theBefore to item 1 of temp
    set theRest to (the rest of temp) as text
    set AppleScript's text item delimiters to od
    return theBefore
end myBefore

to myAfter(subStr, mainStr)
    set od to AppleScript's text item delimiters
    set AppleScript's text item delimiters to subStr
    set temp to text items of mainStr
    set theRest to item 1 of temp
    set theAfter to (the rest of temp) as text
    set AppleScript's text item delimiters to od
    return theAfter
end myAfter
-- 
David Leitch  JPMorgan [EMAIL PROTECTED]  +612 9220 1609



-- 
To unsubscribe:               <mailto:[EMAIL PROTECTED]>
To search the archives: 
          <http://www.mail-archive.com/entourage-talk%40lists.boingo.com/>

Reply via email to