Rép: Wait Until Process Completion
Rép: Wait Until Process Completion
- Subject: Rép: Wait Until Process Completion
- From: KOENIG Yvan <email@hidden>
- Date: Tue, 13 May 2008 16:29:14 +0200
Le 13 mai 2008 à 16:05, Mark J. Reed a écrit :
As Mark's post is public,
my response must be public too ;-)
On Tue, May 13, 2008 at 9:47 AM, KOENIG Yvan <email@hidden>
wrote:
So this one would work sparing some cycles ;-)
This is Applescript. Sparing cycles is way down on the list of things
to worry about...
I typed a smiley ;-)
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; 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
OK, I was wondering why generate a fake error to exit a block when it
is not necessary.
Now, I know your point of view, thread closed ;-)
Yvan KOENIG
_______________________________________________
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