Re: Delaying a script
Re: Delaying a script
- Subject: Re: Delaying a script
- From: Christopher Nebel <email@hidden>
- Date: Tue, 18 Jan 2005 15:08:25 -0800
On Jan 18, 2005, at 10:46 AM, Klaas.Lists wrote:
My script is using a DO SHELL SCRIPT action,
which returns a result (via the Clipboard).
It would not work, DISPLAY DIALOG result would
not show the correct value, until I realised
that my script would continue running, not
waiting for the DO SHELL SCRIPT to finish.
What I would like to know: What is the accepted
way to wait in AppleScript, without a busy loop?
Well, you could use the "delay" command, but that just takes a number
of seconds to wait -- there's no command to wait for a condition. You
can get away without an actual loop in some cases by using an "on idle"
handler, which gets called periodically if your script is saved as an
application.
However, the fact that you're having this problem in the first place is
sort of weird -- usually people have the reverse problem; they want "do
shell script" to *not* stop execution of their script. A few things to
consider:
1. Did you deliberately background the process using "&"? If so, stop
doing that.
2. If the command is somehow detaching itself, does it have an option
to not do that?
3. Why use the clipboard? If the shell command has output, it will be
returned as the result of the "do shell script" command. For example:
set x to do shell script "echo foo"
x --> "foo"
You may find <http://developer.apple.com/technotes/tn2002/tn2065.html>
helpful.
--Chris Nebel
AppleScript Engineering
_______________________________________________
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