6 Replies Latest reply on Mar 19, 2014 7:57 PM by Simon Dav

    How to cancel all alert at once

    Simon Dav Level 1

      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[i];

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

              if (curLayer.name == layersToTargetNameArray[j]) {

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

                  // 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

        • 1. Re: How to cancel all alert at once
          W_J_T Level 4

          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.

          • 2. Re: How to cancel all alert at once
            Simon Dav Level 1

            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

            • 3. Re: How to cancel all alert at once
              W_J_T Level 4

              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?

              • 4. Re: How to cancel all alert at once
                Simon Dav Level 1

                The thing is simple,

                 

                Find the layer names are true in array and Export single Pdf, else exit and alert "Check layer names".

                 

                The baseName(name) is a function

                 

                var docName = baseName(name);

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

                • 5. Re: How to cancel all alert at once
                  W_J_T Level 4

                  Simon Dav wrote:

                   

                  The thing is simple

                   

                  Ok, looking forward to see your final working result then. You're doing great so far copying and pasting all the codes provided by others or found done from others, let us know what you come up with in the end.

                  • 6. Re: How to cancel all alert at once
                    Simon Dav Level 1

                    What you mean of copying and pasting all the codes, are you an super expert in java, then why your coding comes with worng?

                     

                    If then give a code for exiting the alert at one time as above my first quesion? I am a learn, learner, learning always...