Answered
Error: Expected: ; when drag and dropping .JSX
I wrote a script for turning on and off layer combinations and exporting.
The issue I have now is, the script works when I hit Load on UXP tool, and photoshop executes all the functions, but when I drag and drop it as a .jsx into photoshop, it throws all kinds of errors:
For example, this line with the "for...) {" code is throwing: Error 25: Expected: ;.
for (let i=0; i<max; i++) {
//some code to turn on layers
}
Any async functions throws this error: Error 25: Expected: ;.
async function makelyrvis(layer) {
await window.require("photoshop").core.executeAsModal( () => {
layer.visible = true;
});
}
I tried making these functions not async, and got this: Error 23: ) does not have a value.
For the line with "window.require..."
function makelyrvis(layer) {
window.require("photoshop").core.executeAsModal( () => {
layer.visible = true;
});
}
Like I said, the code runs completely fine from UXP Tool, these errors only happen when I use the jsx drag and drop.
The only reason I'm even trying drag and drop is because I can't get the export part of the script to work from UXP tool. IE:
function savePNG(layerName) {
displayDialogs = DialogModes.NO
if (BridgeTalk.appName == "photoshop") {
app.bringToFront;
}
var newFile = new File("D:/Temp/" + layerName + ".png");
var pngOptions = new PNGSaveOptions();
pngOptions.compression = 0
pngOptions.interlaced = false;
app.activeDocument.saveAs(newFile, pngOptions, true, Extension.LOWERCASE);
}
This piece of code won't run in UXP tool, but if I put it by itself in a jsx and drag and drop it into photoshop, it runs fine.
So I guess what I'm asking is, how can I make all my code run either with jsx drag and drop, or with UXP tool?
