Title: Re: Scripting The From Account
On 8/11/02 00:42, Paul Berkowitz wrote:

> On 8/10/02 9:35 PM, "George Clark" <[EMAIL PROTECTED]> wrote:
>
>> Obviously if you delete any item used in a script, whether you refer to it by
>> name or by ID number, the script will error, but that’s another story.
>
> (Except if you recreate an item with the same name, referring to it by name
> will still work, whereas by ID won't. So take your pick - are you more
> likely to change the name of an item - in which case using ID is better - or
> delete it and re-make it - in which case name is better.)

So use both and make the script as universal as possible:

    try
        set acctname to name of POP account ID 2
        set acctID to 2
    on error
        set acctname to "main account"
        set acctID to 0 -- ID's start at 1
    end try

    if acctID = 0 then
        try
            set acctID to ID of POP account acctname
         on error
            display dialog "The account you’re trying to use does not exist!"
            return
        end try
    end if

    make new draft window with properties{account:POP account acctname}


Perhaps it’s just my way of doing things, but I’m much more likely to just edit an existing item rather than deleting it and adding another item with the exact same name, if that’s the end result I want. It’s also more likely that I’d rename something (or move a folder) rather than delete/recreate with a new name. Something like the above would allow for the vast majority of scenarios, though.

George

--
George Clark - [EMAIL PROTECTED]

Reply via email to