I have a script that check pathItem and show an alert if condition is wrong, but if there is more than 1 mistake, the alert will display as many time it is. I just want it show only once. How do I fix it?
#target photoshop
var doc = app.activeDocument;
var pLen = doc.pathItems.length;
var pArray = [];
for(var i=0;i<pLen;i++){
pArray.push(doc.pathItems[i].name)
}
for(var i=0;i<pLen;i++){
var curPath = doc.pathItems.getByName (pArray[i]);
if(curPath.name == 'Freistellerpfad' && curPath.kind == "PathKind.CLIPPINGPATH")
{}
else if (curPath.name == 'Ausschnitt BR' && curPath.kind == "PathKind.NORMALPATH")
{}
else {alert(doc.name + '\n' + "Wrong path" + '\n' + pArray[i])}


I wasn't sure if that was possible, but I got it to work. The key here is
displayDialogswhich can be set to ALL, ERROR or NO.So now we need to create an error: In my example we deliberate create an error (by sampling a colour that's off the image) And then correct it.
Note that setting
displayDialogswill affect the next script that's run. Useful for switching off if you ever have any scripts with text :D