• 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: Loops
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Loops


  • Subject: Re: Loops
  • From: Michael <email@hidden>
  • Date: Fri, 1 Feb 2008 04:42:29 -0800

Thank you Neil.

On Feb 1, 2008, at 4:32 AM, Neil Faiman wrote:

On Feb 1, 2008, at 1:59 AM, Michael wrote:

Question 1) Will AS "wait" for the action to be completed eg moving a file
2) How does it know that the action has been successfully transacted ( assuming the answer to 1 is yes)


3) Is it ever possible for a loop to "outpace" it's asked for action.

1) In general, when a script tells an application to do something, it sends a message to the application, and waits for the application to send back an "I'm done, and here's the result" message before it continues.


2) The script also starts a timer when it sends the message to the application. If the timer runs out before a message comes back, the script gets an "application timed out" error. (The default timer is 60 seconds; you can change that if you know that some operation is likely to take a long time.) The script can catch the time-out error with an error handler and can continue executing or do something else.

3) The script can also use the "ignoring application responses" modifier to just send the message to the application, and not bother waiting for a reply. In this case, the script has no direct way of knowing when or if the operating has completed, but it can use indirect methods to check (for example, looking for the file in the destination folder).

4) In theory, if you don't use "ignoring application responses" a script shouldn't be able to "get ahead of" the application, since it always waits for the application to complete an operation before it does the next thing (see 1). But practice doesn't always match theory. A few days ago I looked at the problem of enabling or disabling fonts in Font Book. It turned out that a loop over all the fonts, telling Font Book to enable each of them, died after enabling only one or two; but inserting a one second delay in the loop fixed the problem. We never figured out the precise cause; but it certainly sounds like Font Book was returning to the application before it had really finished the enabling a font, so that sometimes it tripped over itself when it was asked to enable the next font before it had finished the previous one.

Still, the normal way to script would be to assume that following a script statement, any operations it requested will be complete, and not to worry about weird cases like (4) until they happen.

Regards,

Neil Faiman

_______________________________________________ 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: Loops (From: Neil Faiman <email@hidden>)

  • Prev by Date: Re: Loops
  • Next by Date: Re: Loops
  • Previous by thread: Re: Loops
  • Next by thread: Re: Loops
  • Index(es):
    • Date
    • Thread