• 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: Stay-open & Idle Conditionally
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Stay-open & Idle Conditionally


  • Subject: Re: Stay-open & Idle Conditionally
  • From: Graff <email@hidden>
  • Date: Thu, 28 Oct 2004 14:35:00 -0400

You can just have the script tell itself to quit:
----
on idle
	display dialog "still running"
	return 5
end idle

on run
	-- do whatever startup checks you want here
	set startupChecks to false

	if startupChecks = false then
		quit
	end if
end run
----

If you don't want the applet to quit but you also don't want the stuff in the idle handler to run when the startup checks are false then set a flag variable and use that to determine what to do in the idle handler:
----
global startupChecks


on idle
	if startupChecks = true then
		display dialog "still running"
		return 5
	else
		return 30
	end if
end idle

on run
	-- do whatever startup checks you want here
	set startupChecks to false
end run
----

You'll notice that you can also change the idle interval in the same way, just return a different value and the idle handler will run again in that many seconds. Effectively by just returning a value you are setting the idle handler to do nothing. This is just about the same as not running an idle handler since the idle handler uses little processor time by itself.

- Ken

On Oct 28, 2004, at 1:06 PM, Todd Blume wrote:

I've got a stay-open script that does some environment checks when it runs. I'd like the idle handler to only run iff the start-up checks are OK, and to exit otherwise. What the best way to do this?

_______________________________________________ Do not post admin requests to the list. They will be ignored. Applescript-users mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
References: 
 >Stay-open & Idle Conditionally (From: Todd Blume <email@hidden>)

  • Prev by Date: Re: text item delimiters
  • Next by Date: Re: Excel 2004 Scripting Block
  • Previous by thread: Stay-open & Idle Conditionally
  • Next by thread: sending SMS from Address book?
  • Index(es):
    • Date
    • Thread