Paul,

Here is the whole (short) script, so you can see context of what variables
I'm feeding.

<script: ill wrapped, I'm sure>

property replyAcct : ""
tell application "Microsoft Entourage"
    if replyAcct = "" then -- get an acct from the pop-up
        if class of front window is not draft window then
            display dialog "Open a message draft window (or click reply to
an existing message).  Set the account pop-up to the account that you would
like this script to use, then run the script again." buttons {"OK"} default
button "OK" with icon 1
            
        else -- if draft window is open in the front
            display dialog "You selected \"" & name of account of front
window & "\" as the account you want this script to use. Is that correct?"
buttons {"Yep", "Nope", "Cancel"} default button "Yes"
            
            if button returned of result is "No" then
                display dialog "Set the account pop-up in the current
message to the account you'd like this script to use, and then run the
script again." buttons {"Cancel"} default button "Cancel" with icon 1
            else
                if button returned of result is "Yes" then
                    set replyAcct to account of front window -- set the
property to the chosen account
                    display dialog "I have registered \"" & replyAcct & "\"
as the acct to use when this script is invoked." buttons {"OK"} default
button "OK" with icon 1
                end if
            end if
        end if
    else -- an acct property exists, so do it
        if class of front window is draft window then -- we're cool
            set theMsgWin to front window -- does this coerce text?
            set account of theMsgWin to replyAcct -- here we do the actual
change           
        else -- Doh!
            beep
            display dialog "I can't change the account, because there is no
new message window in front." buttons {"OK"} default button "OK" with icon 0
        end if
    end if   
end tell

</end script>


NOTE:  This does work...even though the error dialog appears.  Go figua'!


On 2/9/01 10:52 AM,  Paul Berkowitz <[EMAIL PROTECTED]> wrote :

> On 2/9/01 6:38 AM, "G Wood" <[EMAIL PROTECTED]> wrote:
> 
>> The script works fine, even though I get an error dialog.
>> 
>> Here is the script snip:
>> 
>>   ...
>>   set theMsgWin to front window
>>   set account of theMsgWin to replyAcct
>>   ...
>> 
>> 
>> Here is the error:
>> 
>> [Can't make <<class popA>> id33 of application "Microsoft Entourage" into a
>> string.]
>> 
>> The acct DOES change, and the setup DOES work. (When I invoke the script for
>> first run, it "takes" the new acct; after the first run, the acct pop-up is
>> properly switched when script is run.)
>> 
>> So:  what's the error?  And:  why does it work anyway? And: how can make it
>> go away?
>> 
> 
> Gary,
> 
> You're giving us two lines of the script, but not what you're feeding into
> the variable 'replyAcct'. It sounds as if you may be trying to do this:
> 
>   set replyAcct to "Some Name"
>   set theMsgWin to front window
>   set account of theMsgWin to replyAcct
> 
> whereas what the applescript syntax requires is:
> 
>   set replyAcct to POP account "Some Name"
>   set theMsgWin to front window
>   set account of theMsgWin to replyAcct
> 
> 
> What AppleScript really does, and needs, is this:
> 
>   set replyAcct to POP account id 33
> 
> That is defining the variable as an object of  POP account class, which lets
> you set the account of a draft window to that variable two lines later. If
> you look in the Entourage Dictionary under 'application', meaning Entourage
> itself, you'll see the various elements of the application (like almost any
> element) defined , for example, like this:
> 
>       window  -- by numeric index, name, relative position, test
>       POP account -- by numeric index, test
> 
> Actually, this appears to be an error, since you can refer to a POP account
> by name or relative position as well as by numeric index and test. (Dan?)
> But Script Editor's Event Log and Result Window, or Smile's Output Windows,
> will show that the other versions are always "translated" back to 'numeric
> index', id number.  If you write
> 
>   POP account "Some Name" -- by name
> 
> you'll see the result as
> 
>   -- POP account id 33
> 
> Similarly
>   
>   POP account 17  -- by relative position
>   -- POP account id 33
> 
> and the wonderful implementation of "whose clauses" in Entourage:
> 
>   first POP account whose name starts with "Some" -- by test
>   -- POP account id 33
> 
> or even
> 
>   first POP account whose email address contains "domain" -- by test
>   -- POP account id 33
> 
> But if you just try
> 
>   "Some Name"
>   -- "Some Name"
> 
> or 
> 
>   "[EMAIL PROTECTED]"
>   -- "[EMAIL PROTECTED]"
> 
> you'll just get the the string repeated back to you because that's all it
> is, even if it's in an Entourage tell block.
> 
> So if you write:
> 
>   tell application "Microsoft Entourage"
>       set replyAcct to "Some Name"
>       set theMsgWin to front window
>       set account of theMsgWin to replyAcct
>   end tell  
> 
> you'll get an error. Now when I do that, I actually get a different error
> 
>   -- ERROR: "Microsoft Entourage expected a reference
> 
> and it doesn't change, so maybe you're doing something different. Or
> AppleScript 1.1.2 (OS 8.1) may give a different error than As 1.5.5 (OS
> 9.1).
> 
> But when I make the first line the equivalent of
> 
>     set replyAcct to POP account "Some Name"
> 
> using a real account name, it does work without any errors. So that's why I
> suspect you're defining the variable representing the account incorrectly,
> even though I can't get the same error with my system. With more
> information, I could probably figure this out for you.
> 
> HTH.



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

Reply via email to