• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: New to applescript: year of
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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:

De :   email@hidden
Objet : Rép : New to applescript: year of
Date : 27 septembre 2006 19:11:52 HAEC
À :   email@hidden


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


Philip Aker
email@hidden


 _______________________________________________
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

References: 
 >Re: New to applescript: year of (From: Yvan KOENIG <email@hidden>)
 >Fwd: New to applescript: year of (From: Yvan KOENIG <email@hidden>)
 >Re: New to applescript: year of (From: Francis Derive <email@hidden>)
 >Re: New to applescript: year of (From: Emmanuel <email@hidden>)
 >Re: New to applescript: year of (From: Yvan KOENIG <email@hidden>)
 >Re: New to applescript: year of (From: Philip Aker <email@hidden>)
 >Re: New to applescript: year of (From: Yvan KOENIG <email@hidden>)
 >Re: New to applescript: year of (From: Philip Aker <email@hidden>)
 >Re: New to applescript: year of (From: Yvan KOENIG <email@hidden>)

  • Prev by Date: Re: New to applescript: year of
  • Next by Date: Rép: New to applescript: year of
  • Previous by thread: Re: New to applescript: year of
  • Next by thread: Re: New to applescript: year of
  • Index(es):
    • Date
    • Thread