"Main" and "Session" Targetengine Paradox.
1) I need to use a "session" targetengine because I a using a "window" type UI window which like the "palette" type cannot be run using the "main" target engine.
2) I want however that on the press of a button on the UI a script should be run in the "main" targetengine as it uses a lot of memory which I want dumped on conclusion of the script's execution.
3) I would like to avoid using 2 separate files one with the UI which activates the other file with the main function using the doScript command but my feeling is that this might be the only option. I would however like to know how to do this as I don't know
.
The script below illustrate one of my pathetic (failed) attempts at solving the problem.
Would much appreciate help on the problem ![]()
#target "InDesign"
#targetengine "session"
target = "#target 'InDesign'";
targetengine="#targetengine 'main'";
w = new Window ("window", undefined, undefined,{ resizeable: true, borderless: false} );
myPanel = w.add ("panel");
w.add ("statictext", undefined, "main");
mb1=w.add ("button", undefined, "Press here!");
w.show();
mb1.onClick = function () {
app.doScript(target,ScriptLanguage.javascript, undefined, UndoModes.entireScript);
app.doScript(targetengine,ScriptLanguage.javascript, undefined, UndoModes.entireScript);
app.doScript(test, ScriptLanguage.javascript, undefined, UndoModes.entireScript);}
myVarm = "session target engine";
function test(){
alert("If you don't see this alert then the function is not being executed");
ww = new Window ("window", undefined, undefined,{ resizeable: true, borderless: false} );
myStatic = ww.add ("statictext", [0, 0, 700, 100], "If this stays on the screen then the target engine has not been changed to \"main!\"\r\rIf You can get this message not to stay on the screen then you are a better scripter than me\r\rThis is not a very difficult achivement !!",{multiline: true });
myStatic.justify = "center";
ww.show();
myMainVar = "Should so error if value is tried to be got from the data browser after the script has run";
}