Maybe this will work. Add the following line to the end of “script a”: return true
Then, use something like this in the script that runs the other scripts. If “script a” takes a long time to run, you might want to increase the length of the delay in the repeat loop.
set script_a_complete to false
set script_a_complete to run script "path:to:script a"
repeat
delay 1
if script_a_complete is true then
exit repeat
end if
end repeat
run script "path:to: script b"
There are a number of methods in which you can do this. I am working on a similar scheme where a master script tell other scripts to run scripts across a network. The difficulty is finding what method would work best for you.
Here are a couple of ideas:
1.) Continue the method that Rob has outlined. You just have to hammer out the path to the script. It sounds like from your error message that you are using a Finder style path (file a of folder b of folder c), in which you may need to wrap it in a “tell app FInder” block. Or, use a “:” delimited path (c:b:a) Just a hunch on the error, haven’t tested it.
2.) MasterScript loads scriptA as a library, runs it until it is completed, then loads scriptB as a library, runs it, etc. This is similar to the first option, but the MasterScript loads the subscripts into memory, and runs them. It becomes a bit easier to know when the first one is complete, and then can go to the next script.
3.) This one is a bit more complex, but I use it for more complex solutions.
a.) Save MasterScript, ScriptA, and ScriptB as stay-open scripts. You can then have Master Script to tell ScriptA to do its thing (its thing should be wrapped in a handler), the Masterscript would wait for the response, and then can tell ScriptB to do its thing.
b.) The real complexity is optional and I don’t want to confuse things, but you may need to use it. By using solution 3a, your MasterScript will wait until ScripA is done and returns something. You may want your MasterScript to continue doing something while ScriptA is working. If this is what you want, then have MasterScript tell ScriptA to do its thing “ignoring application responses”. MasterScript tells ScriptA, and then continues doing its thing, not caring what ScriptA is up to. This creates additional headache for timing and execution, because now you don’t know when ScriptA is done! So then you have to set up a status property in ScriptA, and maybe a handler that will return that status property when asked. It gets more complicated than you probably need, but I don’t know what you are trying to do, so I thought I would toss it out there anyway.
Here are some samples based on option 2 that I outlined in my previous post.
save the following as a compiled script named “library_scriptA”
on doScript(theMsg)
display dialog (theMsg & " scriptA")
end doScript
save the following as a compiled script named “library_scriptB”
on doScript(theMsg)
display dialog (theMsg & " scriptB")
end doScript
save the following as a script named “masterScript”. Make sure you change your paths!
set scriptA to load script file "Queen Elvis:Users:bhays:Desktop:library_scriptA"
set scriptB to load script file "Queen Elvis:Users:bhays:Desktop:library_scriptB"
tell scriptA
doScript("YEEHAW!")
end tell
tell scriptB
doScript("Now we're cooking with butter!")
end tell
I am on OSX, but it should work fine under 9. I think this option would work nicely for you, and it would be easy to add more scripts to the Master script as needed.