Skip to main content
Known Participant
March 13, 2014
Question

How to cancel all alert at once

  • March 13, 2014
  • 1 reply
  • 1017 views

Hi All,

I am trying to close alert at once but the loop continues the alert, how can I stop the alert at once

var doc = app.activeDocument

var layersToTargetNameArray = ["Background", "Artwork", "diecut", "size", "sign off panel"];

for (var i = 0, il = doc.layers.length; i < il; i++) {

    var curLayer = doc.layers;

    for (var j = 0, jl = layersToTargetNameArray.length; j < jl; j++) {

        if (curLayer.name == layersToTargetNameArray) {

            // --------------------------------------------

            // do something if layer name found

with (doc) {

var docName = baseName(name);

var pdfOptions = new PDFSaveOptions();

pdfOptions.PDFPreset = '[High Quality Print]';

var saveAsPath = new File('~/Desktop/Watched Folder/Out/' + docName + '.pdf');

saveAs(saveAsPath, pdfOptions);

}

            curLayer.visible = false; // basic example

        } else {

            // --------------------------------------------

            // do something else if layer name not found

            alert ("Check layer name");

        }

    }

}

Thanks in advance

Simon

This topic has been closed for replies.

1 reply

Inspiring
March 13, 2014

Simon Dav wrote:

curLayer.visible = false; // basic example

First of all you can remove that ^ as it was just to show the example was working when I posted in the other thread, its not relative to you and your outcome.

Simon Dav wrote:

alert ("Check layer name");

Is this the alert you mean? Just delete it, what is it for?

Otherwise maybe, you're wanting and should look in the documentation for:

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;

app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;

Read up on those they may be what you want, otherwise you probably need to explain further.

Known Participant
March 14, 2014

Hi W_J_T,

Thanks for your reply,

W_J_T wrote:

Simon Dav wrote:

curLayer.visible = false; // basic example

First of all you can remove that ^ as it was just to show the example was working when I posted in the other thread, its not relative to you and your outcome.

Simon Dav wrote:

alert ("Check layer name");

Is this the alert you mean? Just delete it, what is it for?

Otherwise maybe, you're wanting and should look in the documentation for:

app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS;
app.userInteractionLevel = UserInteractionLevel.DISPLAYALERTS;

Read up on those they may be what you want, otherwise you probably need to explain further.

The script is exporting pdf of defind layer names found or not found, but it shouldn't do like that, export pdf only the layer names are true else exit

This is what I am trying to do

No problem with alerts

Thanks

Simon

Inspiring
March 14, 2014

Simon Dav wrote:

How to cancel all alert at once: I am trying to close alert at once but the loop continues the alert, how can I stop the alert at once

Simon Dav wrote:

No problem with alerts

Ok? It must have got lost in translation or something then, because that's alot of "alerts"!

Simon Dav wrote:

The script is exporting pdf of defind layer names found or not found, but it shouldn't do like that, export pdf only the layer names are true else exit. This is what I am trying to do.

Yes, I assumed you were trying to do something when I saw all the code you were trying to cobble together. So anyway, are you hoping the targeted layers (from the array) end up in a single PDF or separate PDF's? You need to explain better and be more descriptive given the whole "alert" thing didn't go so well. Really though, you should read the documentation some instead of just cobbling code together haphazardly. I see your code has a function you didn't show, "baseName" where did you copy the code from?