Re: Still don't understand timeout
Re: Still don't understand timeout
- Subject: Re: Still don't understand timeout
- From: Axel Luttgens <email@hidden>
- Date: Fri, 19 Aug 2011 22:49:48 +0200
Le 19 août 2011 à 22:21, Robert Poland a écrit :
> Steve,
>
> You're telling me that a single action like "set numberOfItemsInWindow to "error" (below) can't be controlled with the "timeout" function?
>
> set numberOfItemsInWindow to "error"
> try
> with timeout of 2 seconds
> tell application "Finder"
> activate
> tell application "System Events"
> tell process "Finder"
> tell menu 1 of menu bar item "Edit" of menu bar 1
> click menu item "Select All"
> end tell
> end tell
> end tell
> tell application "Smile" to chrono
> set itemsInWindow to selection -- selection is a large folder, over 220 items.
> tell application "Smile" to set x to chrono
> set x to "A - " & x
> set numberOfItemsInWindow to count of itemsInWindow
> end tell
> end timeout
> on error
> beep 3
> tell application "Smile" to set x to chrono
> set x to "B - " & x
> end try
>
> tell application "Finder" to select {} -- deselect choice(s)
> tell application "System Events"
> activate
> display dialog x & return & numberOfItemsInWindow as text
> end tell
Hello Robert,
The single action you are speaking about in fact consists of many commands *targeted to applications*: the Finder, System Events, and Smile.
Your "with timeout" block controls each of those commands; for it to be effective, one of those commands (for example, 'tell application "Finder" to activate') would have to last for more than two seconds for having AppleScript to "give up" as described in my previous post.
But this clearly is not cumulative: even if, for some reason, activating the Finder requires 1,999 seconds, *each* of the subsequent commands targeted to applications still has two seconds to complete.
HTH,
Axel
_______________________________________________
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