Re: New to applescript: year of
Re: New to applescript: year of
- Subject: Re: New to applescript: year of
- From: Philip Aker <email@hidden>
- Date: Thu, 28 Sep 2006 05:39:20 -0700
On 2006-09-28, at 03:53:28, Yvan KOENIG wrote:
Either it's working or it ain't. If it's not working I can post an example script which works OMM (OS X 10.4.7/Mail 2.1).
The two versions passed in this message:
Objet : Rép : New to applescript: year of Date : 27 septembre 2006 19:11:52 HAEC
works flawlessly but of course I am interested to "read" an other soluce.
I no longer have those messages but the problem I referred to was the loop:
repeat with myMessage in (every message of mailbox laSource)
When you have a situation when one of the items is moved out of the container,
... then move myMessage to mailbox laDestination
then the container is altered -- it no longer contains the number of items it thought it had when it started -- and the container count is compromised. This is clearly shown in the error:
get item 4 of every message of mailbox "zzz" "Erreur dans Mail : NSReceiverEvaluationScriptError: 4"
whereas the previous enumerated items passed successfully.
Hamish Sanderson has made an excellent post to illustrate:
tell application "Mail" move (every message of mailbox laSource whose date received ≥ startDate and date received < endDate) to mailbox laDestination end tell
Here, he bypasses a loop construct entirely and deals directly with the result list of the query.
The intent of my post was to show that if you are going to use a loop (which may be necessary if the search criteria is complicated), then only load the input list in the loop -- don't delete or move there:
tell application "Mail" set mlist to {} tell mailbox sbox set mcount to count of messages repeat with m from 1 to mcount if (somecriteria is true) then set end of mlist to message m end if end repeat end tell move mlist to mailbox dbox end tell
|
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden