• 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: Mail GUI script error
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Mail GUI script error


  • Subject: Re: Mail GUI script error
  • From: "koenig.yvan" <email@hidden>
  • Date: Mon, 25 Feb 2013 20:39:29 +0100


Le 25/02/2013 à 17:29, Luther Fuller <email@hidden> a écrit :

I was away from my computer for a couple of days before I could get back to testing this.
I've found another problem in Mt Lion (10.8.2) that deserves mention.
(But, has nothing to do with GUI scripting.)

My script writes a message as a pdf file to the desktop, then …

set tempPrintFolder to (path to desktop)
tell application "Finder"
activate
repeat 50 times -- wait for file to appear
if (exists file tempFileName of tempPrintFolder) then exit repeat
delay 0.1
end repeat
if not (exists file tempFileName of tempPrintFolder) then error "The pdf document was not created."
set pdfTempDoc to (file tempFileName of tempPrintFolder) as alias
set pdfDocAlias to (duplicate pdfTempDoc to destinationFolder with replacing) as alias

The problem I encountered was a duplicate file that was unreadable/un-openable in Preview.
In other words, the file was corrupted.
The fix was to add a 'delay 1' ...

set tempPrintFolder to (path to desktop)
tell application "Finder"
activate
repeat 50 times -- wait for file to appear
if (exists file tempFileName of tempPrintFolder) then exit repeat
delay 0.1
end repeat
if not (exists file tempFileName of tempPrintFolder) then error "The pdf document was not created." 
set pdfTempDoc to (file tempFileName of tempPrintFolder) as alias
delay 1 -- wait for file tempFileName to complete writing  <<<<<<<<<<<<<<<<<<<< ADDED
set pdfDocAlias to (duplicate pdfTempDoc to destinationFolder with replacing) as alias

This bothers me. The file exists at the end of the repeat loop, but it has not finished writing.
I've never encountered this problem in Lion or previous systems. It seems to me that Mt Lion
should not make the file available for reading until it has finished writing.
(This would seem to me to be standard procedure in any OS !)

Is this a possible bug in Mt Lion ?

In my scripts, I insert always a loop checking that the files are completely written on the disk before working upon them.
It's easy for flat files but I don't know a clean way to do that for packages.

Yvan KOENIG (VALLAURIS, France) lundi 25 février 2013 20:38:48



 _______________________________________________
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

  • Follow-Ups:
    • Re: Mail GUI script error
      • From: Luther Fuller <email@hidden>
References: 
 >Mail GUI script error (From: Luther Fuller <email@hidden>)
 >Re: Mail GUI script error (From: Brian Christmas <email@hidden>)
 >Re: Mail GUI script error (From: Luther Fuller <email@hidden>)
 >Re: Mail GUI script error (From: Brian Christmas <email@hidden>)
 >Re: Mail GUI script error (From: Luther Fuller <email@hidden>)
 >Re: Mail GUI script error (From: Luther Fuller <email@hidden>)
 >Re: Mail GUI script error (From: Luther Fuller <email@hidden>)

  • Prev by Date: Re: Mail GUI script error
  • Next by Date: Re: Mail GUI script error
  • Previous by thread: Re: Mail GUI script error
  • Next by thread: Re: Mail GUI script error
  • Index(es):
    • Date
    • Thread