Copy link to clipboard
Copied
I'm developing a HTML5 panel for Photoshop and I have a problem.
I'm using CSInterface.evalScript() to call my JSX function - which returns a bunch of values.
The return is then handled by a function that resides as the second parameter to evalScript() - so far nothing strange (code example below).
var csInterface = new CSInterface();
var lolk = 10;
csInterface.evalScript("myJSX('param1')", function(result){
lolk = result[8];
});
alert(lolk); // gives 10 - not the value returned from myJSX
The problem here is that I really, really need to be able to output things into the global scope in main.js. But with the above code you will not overwrite the global variable lolk. Instead the assignment is only within the scope of evalScript.
Copy link to clipboard
Copied
try
lolk = 10;
and not
var lolk = 10;
Copy link to clipboard
Copied
The issue here is that evalScript is returning result[8] asyncronously. You need to put the alert inside the callback after you assign result[8] to lolk.
Copy link to clipboard
Copied
result[8] is the callback
Copy link to clipboard
Copied
Hi Heimdaal,
Did you ever find a solution this problem? I'm running into the same issue where i cannot access the updated variable value outside the callback function.