-
1. Re: Can a script execute another script?
Ian Proudfoot Aug 14, 2011 9:53 AM (in response to Michael Müller-Hillebrand)Hi Michael,
You could use the eval() method to do what you need. Here's a simple example that pops up an alert from the Alert.jsx file.
var scriptFile = File('/c/Projects/ExtendScript/Alert.jsx');
var script;scriptFile.open('r');
script = scriptFile.read();
scriptFile.close();eval(script);
Caution: some say that eval() is evil, use with care.
regards
Ian
-
2. Re: Can a script execute another script?
Wiedenmaier Aug 14, 2011 11:37 AM (in response to Michael Müller-Hillebrand)Hi Michael,
this should also work like this:
CallClient("ScriptingSupport", "[YourPath]\[YourFile].jsx");
I haven't tried it with ES, but in FDK it works well, so I think, it also works with ES in that way.
bye
Markus
-
3. Re: Can a script execute another script?
Michael Müller-Hillebrand Aug 15, 2011 1:18 AM (in response to Ian Proudfoot)Ian,
Thanks a lot for the idea with eval(), but removing the script content from its original location disables features like #include or $.fileName, unless I do some ugly workarounds there.
- Michael
-
4. Re: Can a script execute another script?
Michael Müller-Hillebrand Aug 15, 2011 1:18 AM (in response to Wiedenmaier)Am 14.08.2011 um 20:38 schrieb Wiedenmaier:
this should also work like this:
CallClient("ScriptingSupport", "[YourPath]\[YourFile].jsx");
I haven't tried it with ES, but in FDK it works well, so I think, it also works with ES in that way.
Markus, this looks far better than eval() but unfortunately it does not work.
Well, it would be a recursive call, ScriptingSupport calling itself, which is something different from any other client calling a script.
- Michael
-
5. Re: Can a script execute another script?
Ian Proudfoot Aug 15, 2011 2:17 AM (in response to Michael Müller-Hillebrand)Hi Michael,
#include will work with eval() if you use an absolute file path. The best way to do that is to prepend an #includepath directive to the string that is passed to eval();
Ian
-
6. Re: Can a script execute another script?
Ian Proudfoot Aug 15, 2011 3:57 AM (in response to Ian Proudfoot)Michael, here's another eval() idea:
var scriptFile = File('/c/Projects/ExtendScript/Alert.jsx');
var script = '#include' + scriptFile.fullName;eval(script);
I've tried this and it handles nested #includes and $.fileName. I can't be sure that it would work in every situation however. I feel that there must be a more elegant way...
Ian
-
7. Re: Can a script execute another script?
4everJang Jul 28, 2014 2:36 AM (in response to Michael Müller-Hillebrand)Reviving an old thread, as the answers so far did not solve my current related problem.
I have tried to use both methods ( the CallClient suggested by Markus and the 'eval' suggested by Ian ) but in this case they do not seem to work. I am wondering if there is any option at all:
I have a binary script file (jsxbin) to execute from another script. CallClient does not seem to do anything at all and the 'eval' method clearly expects a jsx file, as it gives me an unspecified syntax error when trying to run a jsxbin file. I am using the jsxbin file as that takes care of all the nasty include file hassle and is a self-contained executable. The problem is that I need to run it from another executable script file and the script to be executed is only known at runtime (as in the problem Michael originally indicated).
Any suggestions ? Anyone at Adobe who knows whether this would work at all ?
Jang
-
8. Re: Can a script execute another script?
Wiedenmaier Aug 10, 2014 4:35 AM (in response to 4everJang)Hi Jang,
CallClient doesn't work from ExtendScript to ExtendScript, as there is the same FDK Client used for executing different scripts. CallClient works only from one FDK Client to another.
So if you want to use CallClient, you need your own small FDK Client, which controls the external script and your script.
AFAIK it's not possible to use eval for jsxbin files.
If the external jsxbin has a command created to execute that function, you can crawl for the command name and execute it with the fcode.
Hope this helps
Markus
-
9. Re: Can a script execute another script?
Klaus Göbel Oct 8, 2014 3:38 AM (in response to Michael Müller-Hillebrand)Hi Michael,
for me, it works with:
$.evalFile("pathToMyFile/myfile.jsxbin")



