Re: Wait Until Process Completion
Re: Wait Until Process Completion
- Subject: Re: Wait Until Process Completion
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 13 May 2008 10:25:38 -0400
Accidentally sent my original reply only to Yvan. And I wouldn't want
the rest of you to miss out on a single episode from this thrilling,
overes thread. :)
---
On Tue, May 13, 2008 at 9:47 AM, KOENIG Yvan <email@hidden> wrote:
> So this one would work sparing some cycles ;-)
It's an Applescript loop that sleeps for a second every iteration.
Sparing cycles is way down on the list of things to worry about... :)
> repeat
> delay 1
> try
> do shell script "ps -p " & pid
> if the result doesn't contain pid then exit repeat
> on error
> exit repeat
> end try
> end repeat
Sure, but I don't like having multiple "exit repeat"s. I think it's
easier to tell what's going on if there's only one loop exit.
Besides, I hate repeating myself. Anytime I see the same programming
statement on two different lines, especially when they're that close
together, I look for a way to abstract out the common bits.
Of course, pure Structured Programming guidelines would argue against
using "exit repeat" at all, in favor of having the exit condition at
the top of the loop. Maybe something like this:
set theResult to pid
repeat while theResult contains pid
delay 1
try
set theResult to do shell script "ps -p" & pid
on error
set theResult to ""
end try
end repeat
--
Mark J. Reed <email@hidden>
--
Mark J. Reed <email@hidden>
_______________________________________________
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