On 8/17/04 10:04 AM, "Jeremy Reichman" <[EMAIL PROTECTED]> wrote:

> Can anyone give me any tips for making scripts that are designed to be used
> with schedules and/or rules?
> 
> Like, for example, what parameters are passed from the schedule/rule itself
> to a script it executes? Anything?

Nothing. It just means that you don't have check for criteria that the rule
already checks for IF you know you will be running the script only from the
rule and not on its own. (Otherwise, there's no harm, except time lost, in
repeating the criterion checking within the script.)

The rule criteria filters _which_ messages will be sent to the script. It's
a good idea to apply such criteria by the rule, not the script, to limit the
numbers of messages sent to the script, since the script runs on each such
message separately. I'm not certain whether the messages queue up one by one
(I think so) or whether separate instances of the script can run
simultaneously (I very much doubt it). So the fewer messages get sent to the
script, the better.

The one and only parameter passed form the rule to the script is the message
being filtered. As you probably already know, the message is accessed by the
script this way:

    set theMsg to item 1 of (get current messages)


Scripts being run by a rule process messages one at a time, so 'current
messages' in this context is simply a 1-item list consisting of the message
- NOT all messages queuing up in the Inbox. (Messages awaiting rule
processing are in the appropriate Inbox - local or IMAP - while awaiting
their turn.)

Note that if you select a bunch of messages in a folder and run a script on
them from the script menu, then 'current messages' will be the list of all
the selected messages, bit if you instead Apply a Rule from the Message menu
to them, and this rule runs a script, the rule will run as many times as
there are messages, one by one, and 'current messages' will be just each
message, one at a time, as it's being handled by the rule. So in this case
running the script, rather than the rule, on the selected messages, will be
faster. If you think you might sometimes want to use the script in this
manner, then your script should

    set currMsgs to current messages
    repeat with i from 1 to (count currMsgs)
        set theMsg to item i of currMsgs
        -- do your stuff or call a subroutine(theMsg)
    end repeat

rather than setting theMsg to item 1 as above. It will work just as fast
from a rule, but may well work faster when applied directly to selected
messages. 


-- 
Paul Berkowitz
MVP MacOffice
Entourage FAQ Page: <http://www.entourage.mvps.org/faq/index.html>
AppleScripts for Entourage: <http://macscripter.net/scriptbuilders/>

PLEASE always state which version of Microsoft Office you are using -
**2004**, X  or 2001. It's often impossible to answer your questions
otherwise.


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

Reply via email to