• 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: AppleScript-Users Digest, Vol 6, Issue 44
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript-Users Digest, Vol 6, Issue 44


  • Subject: Re: AppleScript-Users Digest, Vol 6, Issue 44
  • From: Brian Christmas <email@hidden>
  • Date: Wed, 28 Jan 2009 23:34:32 +1100


On 28/01/2009, at 10:47 PM, Jim Brandt wrote:

<Snip>


The error happens immediately after the first file in the folder moves. No stalling,
no wait cursor, just the error. 

If I run the pair again (script B calling script A) it moves the next file and stops with an error.

If I run script A standalone, all files move, with no error.

This was an attempt to not duplicate code, as script A does more than move these files,
its just that it's at this part of the script that I get the error. The first part of the script "A" builds
an email that sends all the files as attachments to a specific email address. That part of
the script works both as standalone and when called from the second script. Its just the
moving of the files part that fails.

Thanks again.

Jim


Jim, I don't know if this will help, but I have two scripts doing similar things to yours, and struck problems.

In the script being called,

1. When referring to the actual emails, I found it necessary to declare the variable referring to the processing email as a global, and also to pass the variable between subroutines. If I did not do this, references to the email became 'unstuck'.

global emailreference
property MailBoxStoreName : "* items to store"

on Mainroutine()
tell application "Mail"
activate
tell application "System Events" to tell process "Mail"
set W to every window
repeat with A in W
tell A
try
if name of A is in {"Activity Viewer", "Addresses", "Mail Connection Doctor", "Previous Recipients", "Photo Browser", "Fonts", "Colors"} then click button 1 of A
end try
end tell
end repeat
end tell
set tempStore to messages of mailbox MailBoxProcessName
repeat with emailreference in reverse of tempStore
my SubRoutine1(emailreference)
end repeat
end tell
end Mainroutine

on SubRoutine1(emailreference)
--do stuff
my subroutine2(emailreference)
end SubRoutine1

on subroutine2(emailreference)
--do stuff
end subroutine2

2. When moving files, never refer to the files directly, but as a variable

repeat with thefiles in contents of thefolder -- this will bomb in a called script after one file is moved, as the  finder refreshes, and the variable loses track of the remaining files
--move file
end repeat

set TheFileList to contents of thefolder -- this works
repeat with thefiles in TheFileList
--move file
end repeat


Hope this helps

Regards

Santa
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

References: 
 >Re: AppleScript-Users Digest, Vol 6, Issue 44 (From: Jim Brandt <email@hidden>)

  • Prev by Date: Re: How do I create a Applescript Interface for my Application
  • Next by Date: Re: How do I create a Applescript Interface for my Application
  • Previous by thread: Re: AppleScript-Users Digest, Vol 6, Issue 44
  • Next by thread: iPhoto in reverse: get photo from pathname?
  • Index(es):
    • Date
    • Thread