Copy link to clipboard
Copied
//DESCRIPTION: Calling Script
(function() {
myScriptFile = File(getScriptFile().parent + "/calledScript2.jsx");
result = app.doScript(myScriptFile, undefined, [3,4]);
alert(result);
function getScriptFile() {
// This function returns the file of the active script, even when running ESTK
try {
return app.activeScript;
} catch(e) {
return File(e.fileName);
}
}
}())
//DESCRIPTION: Called ScriptThis fails dismally. The "called script" returns a value of 0 when called by the other script but fails to run stand-alone with the error "arguments is undefined".
(function (a){
if (a == null) return 0
var sum = 0;
for (var j = 0; a.length > j; j++) {
sum += a;
}
return sum
}(arguments != undefined ? arguments : null))
//DESCRIPTION: Called ScriptIt still doesn't work!!!! This whole mechanism only seems to function properly if both scripts are not anonymous functions. Change the calling script to:
sum = 0;
for (var j = 0; arguments.length > j; j++) {
sum += arguments;
}
sum
//DESCRIPTION: Calling ScriptAnd now I can run the calling script and get an alert that says 7. But the called script can't be run stand-alone and their namespaces aren't protected from each other (not important in this trivial example, but definitely necessary in some of the more complex stuff I've done where I haven't bothered with trying to pass arguments in this fashion).
myScriptFile = File(getScriptFile().parent + "/calledScript2.jsx");
result = app.doScript(myScriptFile, undefined, [3,4]);
alert(result);
function getScriptFile() {
// This function returns the file of the active script, even when running ESTK
try {
return app.activeScript;
} catch(e) {
return File(e.fileName);
}
}
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Copy link to clipboard
Copied
Find more inspiration, events, and resources on the new Adobe Community
Explore Now