im quite a JS noob but trying to script my workflow. I modified a script to my needs, but suddenly the setting of app.-based properties doesnt work in a function anymore:
function myExport(Xquali, Xdpi, XAA, XSP, Xpath, BMcounter) {
switch (Xquali) {
case "Low": app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.LOW; break;
case "Medium": app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MEDIUM; break;
case "High": app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.HIGH; break;
case "Max": alert("?"); app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality.MAXIMUM; alert("!");}
Theres obvious nothing wrong with this snippet, but all properties i try to change cancel my script – and i dont know how to find out why. Do you guys have any idea, why i can change eg jpgexport stuff outside my function, but not in there?
May i suggest a shorter snippet?
function myExport(Xquali) {
if (!Xquali||!(typeof(Xquali)!=String)||!/low|medium|high|maximum/i.test(Xquali) ) return;
app.jpegExportPreferences.jpegQuality = JPEGOptionsQuality[Xquali.toUpperCase()];
}
myExport("low"); //could be Low, LOW, low, loW,loW whatever
alert(app.jpegExportPreferences.jpegQuality);
FWIW