Calling a script within a script
Forums
Hi Brian,
I hope all is well with you.
I'm trying to combine two scripts as follows:
Script A is a standalone that is used regularly.
Script B will not be used often, and it's starting point is the final file produced by Script A. It is not standalone.
I will need to update Script A from time and therefore I think it is better to call it at the beginning of Script B.
(I think this is sensible, as if I paste it into the start of Script B then I would have two files to update).
I have this working fine, except for one problem.
Both Script A and Script B can take a long time to run.
At the end of Script A there is a message box and the user has to click "OK" to finish.
This message is needed when running Script A as a standalone.
However, when I am calling this from Script B this effectively is a pause in the middle, requiring user interaction (click OK)
What I would like to do is to run Script B and not have this pause.
In other words, Script B calls Script A which runs to the end, no message box appears, and Script B continues to the end. No user interaction is needed in the middle.
I am wondering if there is a way to pass the "Ok" when I call Script A?
I tried this but it didn't work (and I didn't really know what I was doing)
Client.RunIDEAScriptEX directory &"\Macros.ilb\Script A.iss", "OK", "","",""
many thanks as always
Phil
Hi Brian, I changed the…
Hi Brian,
I changed the msgbox in each so that I can see what Arg 1 is being returned, and these are the results:
This is Script B
This is Script A
Script A Arg1 : Test
Script B back from Script A
Script B Arg1 : Ok
So what I think I'm seeing is that Script B is sending "test" to Script A, and Script A is sending "Ok" back to script B.
This does makes sense, but when I put these into my actual scripts I am not getting the desired result.
What I was hoping is that this "Ok" is recognised by the message box and treated as if user had clicked "Ok", effectively closing the message box without user interaction.
This is what happens:
I run script B, which calls Script A.
Script A runs to the end, the message box saying Script A is complete appears.
Then everything stops until the user clicks "Ok" on this message box.
Then Script B continues to the end.
What I would like to do - if it is possible - is to override this message box at the end of Script A
I have to have it there when Script A is run as a standalone script (which will be most of the time).
However, when I run Script B this message creates a problem as it requires user interaction in the middle of the script.
(Depending on input file size, each script can take several minutes to run, so it would be more user friendly if this did not happen. The user can hit run, go and make a coffee, and come back to find the results ready).
If this is not possible then that's how it will have to be, but if IDEA can do it then it would make the whole operation much smoother.
All the best,
Phil
Hi Phil,You can do this with…
Hi Phil,
You can do this with the Client.RunIDEAScriptRV function.
Here is an example for Script B
Sub Main
MsgBox "This is script B"
'call script A
Arg1 = "test"
Arg2 = ""
Arg3 = ""
Arg4 = ""
Client.RunIDEAScriptRV "Macros.ILB\Script A.iss", Arg1, Arg2, Arg3, Arg4
'client.RunIDEASCript "Macros.ILB\Script A.ISS"
MsgBox "Script B back from script A"
MsgBox "Arg1: " & Arg1
End Sub
Here is an example for Script A
Sub Main
MsgBox "This is script A"
MsgBox "Arg1: " & Arg1
Arg1 = "OK"
Arg2 = ""
Arg3 = ""
Arg4 = ""
End Sub
Using the RunIDEASCriptRV you can send up to four variables between the scripts. In script B I defined Arg1 as Text and then I redefined in as Arg1 in Script A. When Script A returns to B just check is Arg1 is equal to "OK" and then you can either continue with script B or cancel the operation. Hopefully this makes sense.