Re: Batch Program Processing via AppleScript
Re: Batch Program Processing via AppleScript
- Subject: Re: Batch Program Processing via AppleScript
- From: Benoit Blaquiere <email@hidden>
- Date: Tue, 04 Dec 2001 13:23:17 +0100
>
I am a newbie to AppleScript, so this problem may be already solved.
>
However, I wasn't able to find anything in the archives.
>
>
I have a large number of Absoft Macintosh FORTRAN programs (call them A,
>
B, C, D, etc) that must be executed sequentially. The problem is: B must
>
only start executing after A is completely done, C must only start
>
executing after B is completely done, etc. How can this batch program
>
processing be done using AppleScript? (This is analogous to a simple
>
DOS BAT file.). When I tried, Programs A, B, C, D, etc, all began
>
running at the same time, instead of waiting appropriately.
>
Follows a handler that I used in the past in one of my scripts.
You use it like this :
tell application "Finder" to open "A"
my WaitProcessEnd ("A",1,6,1)
tell application "Finder" to open "B"
my WaitProcessEnd ("B",1,6,1)
...
on WaitProcessEnd(appName, waitProcessLoopDelay, waitProcessLoopMax,
waitProcessEndLoopDelay)
-- Uses a timeout because of non-cooperative applications.
with timeout of 3600 seconds
-- Waits until the application is in the processes list
-- every waitProcessLoopDelay seconds.
-- Gives up after waitProcessLoopMax loops if the application is not
-- in the processes list : some small quick applications don't appear
-- in the processes list.
repeat waitProcessLoopMax times
tell application "Finder" to set processList to name of every process
if processList contains appName then exit repeat
delay waitProcessLoopDelay
end repeat
-- Waits until the application is not in the processes list.
-- Verifies every waitProcessEndLoopDelay seconds.
repeat
tell application "Finder" to set processList to name of every process
if processList does not contain appName then exit repeat
delay waitProcessEndLoopDelay
end repeat
end timeout
end WaitProcessEnd
HTH
Benoit
--
Benoit BLAQUIERE e-mail: email@hidden
Institut Geographique National / IGN Espace
Parc Technologique du Canal - 24, rue Hermes
31527 Ramonville-Saint-Agne cedex - France
Tel: +33 (0)5 62 19 19 45 Fax: +33 (0)5 61 75 03 17