In einem Script hatte ich app.doScript so verwendet,
Code: Alles auswählen
var /*String*/scriptPath = "scriptPath", /*String*/doScriptFile = "[Path]/doscript.jsx";
app.doScript(doScriptFile, ScriptLanguage.JAVASCRIPT, scriptPath, UndoModes.ENTIRE_SCRIPT);
Code: Alles auswählen
main(scriptPath);
/*void*/main()
{
alert(scriptPath);
}
Dann wollte ich zwei Parameter übergeben und die Sache vereinfachen:
In einem Script hatte ich app.doScript so verwendet,
Code: Alles auswählen
var /*String*/doScriptFile = "[Path]/doscript.jsx";
app.doScript(doScriptFile, ScriptLanguage.JAVASCRIPT, ["eins","zwei"], UndoModes.ENTIRE_SCRIPT);
Code: Alles auswählen
main(/*Array*/arguments);
/*void*/main(/*Array*/arguments)
{
alert(arguments); // -> [Object], arguments.length -> 1, arguments[0] -> undefined
}
Nach längerer Suche kam ich dann zu diesem Ergebnis, Caller:
Code: Alles auswählen
// DESCRIPTION shows visibility of variables with doScript
// Dateiname: wpsDemonstrationOfVariablesVisibitlityWithDoScript.jsx
// projPath: C:/Users/WernerPerplies/Source/Workspaces/Singles
// for this Script
// © 2017 by Werner Perplies, EDV-Anwendungsberatung,
// http://www.weepee.de, email: werner.perplies@weepee.de
// [modified]
// created: Sun Jun 11 2017 06:07:5 GMT+0200
// [lastFileProps:({time:"1488208806000", size:14240, checkSum:"-1e342f17", scriptVersion:"1.52", scriptDate:"201706081054"})] // placeholder for wpsIncludes4
// [end of header]
#target indesign-11.064
main();
/*Void*/function main()
{
/*Object*/var showedInCalledDoScript = {one: "main:One", two: "main:Two"};
app.doScript("C:/Users/WernerPerplies/Source/Workspaces/Singles/calledByDoScript.jsx", ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT);
// function in called Script
showShowedInCalledDoScript();
alert(visibleInCallingFunction.one + "\n" + visibleInCallingFunction.two);
}
// throws error!
// visibleInCallingFunction hidden in global scope
alert(visibleInCallingFunction.one + "\n" + visibleInCallingFunction.two);
// hidden in global - this call fails!
showShowedInCalledDoScript();
Code: Alles auswählen
// DESCRIPTION shows visibility of variables with doScript, called by doScript
// Dateiname: calledByDoScript.jsx
// projPath: C:/Users/WernerPerplies/Source/Workspaces/Singles
// for this Script
// © 2017 by Werner Perplies, EDV-Anwendungsberatung,
// http://www.weepee.de, email: werner.perplies@weepee.de
// [modified]
// created: Sun Jun 11 2017 06:07:54 GMT+0200
// [lastFileProps:({time:"1488208806000", size:14240, checkSum:"-1e342f17", scriptVersion:"1.52", scriptDate:"201706081054"})] // placeholder for wpsIncludes4
// [end of header]
// #target indesign-11.064
// visible in calling function - not in global scope!
var visibleInCallingFunction = {one: "doScript:One", two: "doScript:Two"};
/*Void*/function showShowedInCalledDoScript()
{
alert(showedInCalledDoScript.one + "\n" + showedInCalledDoScript.one);
return;
}
Mit JavaScript funktioniert app.doScript() wie ganz normal einfügter Code, die Sichtbarkeit von Variablen hängt ausschließlich vom Ort des Aufrufens ab (aus einer Funktion oder aus dem globalen Bereich!), die einzige Besonderheit scheint die "UnDo-Behandlung" zu sein!