• 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: Still don't understand timeout
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Still don't understand timeout


  • Subject: Re: Still don't understand timeout
  • From: Steve Mills <email@hidden>
  • Date: Fri, 19 Aug 2011 14:16:58 -0500

On Aug 19, 2011, at 14:01:13, Robert Poland wrote:

> If I understand right "with timeout" doesn't end and stop the block. Is there something that will do that?

A timeout is a per-command timeout. So if a *single* command doesn't return control back to the script within the timeout, then it'll force it to return control to the script. The same mechanism is provided as a parameter to the "display dialog" command (giving up after). Try it and you'll see.

If you want to force a loop to timeout once a given time limit is reached, you'll have to measure the time limit yourself.

set startTime to current date

repeat while true
	set nowTime to current date

	if (time of nowTime) - (time of startTime) ≥ 2 then exit repeat

	say "z"
end repeat

The above won't work if startTime is before midnight and nowTime is after midnight. If you anticipate that happening, add the day of the month multiplied by the number of seconds in a month. But then that'll break if you start on the 31st and cross midnight into the 1st of the next month. Didn't there used to be a command called "the ticks" that returned the number of ticks since system boot? That was most useful.

--
Steve Mills
Drummer, Mac geek

 _______________________________________________
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: Still don't understand timeout
      • From: Robert Poland <email@hidden>
    • Re: Still don't understand timeout
      • From: Emmanuel LEVY <email@hidden>
  • Prev by Date: Re: temporary items
  • Next by Date: Re: Still don't understand timeout
  • Previous by thread: Re: Still don't understand timeout
  • Next by thread: Re: Still don't understand timeout
  • Index(es):
    • Date
    • Thread