Title: Re: New Note from Selected Text (trying to write)
On 2/4/01 11:49 AM, "Christian M. M. Brady" <[EMAIL PROTECTED]> wrote:

And what would I need to change to make this create an Event rather than a note?


-- Script from a message sent by Paul Berkowitz
-- on Thursday, October 12, 2000 8:42:53 PM
(* Modified ever so slightly by Jim Baskins on October 18, 2000 from Paul's Make Event Selected Text Script. *)

But it looks as if i never posted it anywhere but here. I'll repair that. it would have been something like this:

-------------------------------Make Event Selected Text--------------------


global selectedMessages

tell application "Microsoft Entourage"
    activate
   --
get the currently selected text
   set selectedMessages to current messages
   set theSelection to the selection
   if class of theSelection = string then
       set selectedText to theSelection --
could be "" if focus is in message text
       set frontMsg to displayed message of window 1
        my MakeEvent(frontMsg, selectedText)
    else
       set selectedText to "" --
to define it
       repeat with theMessage in selectedMessages
           my MakeEvent(theMessage, selectedText)
        end repeat
   end if
   
    --
if there is no text selected, select the current message or messages
end tell

to MakeEvent(theMessage, selectedText)
    tell application "Microsoft Entourage"
        
        --
get the information from the message, and store it in variables
       
        set theName to text returned of (display dialog "Enter a Name for this Event" default answer "Type New Event Name Here")
        if theName = "" or theName = "Type New Event Name Here" then
           set theName to subject of theMessage
       end if
       set theCategory to category of theMessage
       
        if selectedText = "" then
           set theContent to content of theMessage
       else
           set theContent to selectedText
       end if
       --
create a new event with the information from the message
       set newEvent to make new event with properties {subject:theName, category:theCategory, content:theContent}
        
        --
create a link between the message and the new note
       link theMessage to newEvent
       
        --
if there was only one message selected, then open that new note
       if (count of selectedMessages) = 1 then open newEvent
   end tell
   
end MakeEvent



----------------------end script-----------


(I would never have had any code like this, BTW:

       if theName = "" then
       else if theName = "Type New Note Name Here" then
           set theName to subject of theMessage
        end if

That gives you the name "untitled" to the new event or note, if the user makes it blank, rather than the subject of the message. And if that's really what you want, you just just write:

       if theName = "Type New Note Name Here" then
           set theName to subject of theMessage
        end if

and not bother with the first line at all. If you want the note to have the name of the message if the user leaves the dialog blank, then change it to :


       if theName = "" or theName = "Type New Note Name Here" then
           set theName to subject of theMessage
        end if


--
Paul Berkowitz

Reply via email to