4 Replies Latest reply on Sep 23, 2016 5:14 AM by Loic.Aigon

    Alert For cancel button Question.

    cbishop01 Level 2

      Hi all I've been trying to get this to work for a while.  Is there a way to get the below code to work in my alert button.  The trouble i'm having is that this code is a the very end of my Script.  And my cancel button is in the middle.  ANd when i add this to the script it just doesnt work because all the information contained in this alert is below the Cancel Button.  Is there a snippet of code i can place in this alert or in the cancel button area that will display the information in  an alert?  I'm sure i'm leaving important information out so if i'm forgetting to let you know anything let me know..  And the infromation i am displaying on this is from line 700-823(All are in function(){}   .  ) and all my Buttons including my cancel button is lines 392-435.

       

      function DBLS(target, findProps, changeProps){   
         var changes, numberOfChanges, alerts, alerts1, alert2;
          app.findGrepPreferences = app.changeGrepPreferences = null;   
          app.findGrepPreferences.properties = findProps;   
          app.changeGrepPreferences.properties = changeProps;
          changes = app.documents[0].changeGrep();
          numberOfChanges = changes.length;
      // THese alerts
          alerts = [numberOfChanges+"   Double Space", SP+"   Space Period", SC+"  Space Colon", DR+"   Double Return"];
          alerts1 = [EN+"   Important Statement", SDS+"   Material Safety DATA Sheet"];
          alerts2 = [CCH+"  Pink ? to A Contains", CE+"  Pink ? to E Contains ", CK+"  Pink ? to K Contains"];
          alert("Corrections Made:\r"+alerts.join("\r")+"\r-----------------------------------\rImportant and SDS:\r-----------------------------------\r"+alerts1.join("\r")+"\r-----------------------------------\rImportant and SDS:\r-----------------------------------\r"+alerts2.join("\r"));
      
        • 1. Re: Alert For cancel button Question.
          Trevorׅ Adobe Community Professional

          Hi Chris

           

          Can you make a 10 or less line code that can be executed and demonstrates the problem?

          Are you doing?

           

          alert('Hello ' + world);
          var world = world;
          

           

          and getting 'Hello undefined' in which case the solution would be to either swap the order of the lines or use

           

          alert('hello ' + world());
          function world(){return 'world';}
          

           

          HTH

           

          Trevor

          1 person found this helpful
          • 2. Re: Alert For cancel button Question.
            Trevorׅ Adobe Community Professional

            The correct structure for a dialog is as below.

            var w = new Window('dialog');
            w.cancel = w.add('button', undefined, 'Cancel');
            w.ok = w.add('button', undefined, 'Ok');
            w.cancel.onClick = function() {
                w.goForIt = false;
                w.close();
            }
            
            w.ok.onClick = function() {
                w.goForIt = true;
                w.close();
            }
            
            w.show();
            
            if (w.goForIt) {
                alert('hello ' + world());
            } else {
                alert('Canceled');
            }
            function world(){return 'world';}
            
            1 person found this helpful
            • 3. Re: Alert For cancel button Question.
              cbishop01 Level 2

              I'll try but most of the Code is tied into each other.  I'll work on it today.

              • 4. Re: Alert For cancel button Question.
                Loic.Aigon Adobe Community Professional

                @Trevor,

                 

                You don't have to surcharge the widow to determine if the user either chose to go further or cancel. You can set the return code once window is closed (after w.show( was called).

                 

                var w = new Window('dialog');  
                w.cancel = w.add('button', undefined, 'Cancel');  
                w.ok = w.add('button', undefined, 'Ok');  
                w.cancel.onClick = function() {  
                    w.close(0);  
                }  
                  
                w.ok.onClick = function() {
                    w.close(1);  
                }  
                  
                
                
                  
                if ( w.show()==1  ) {  
                    alert('hello ' + world());  
                } else {  
                    alert('Canceled');  
                }  
                function world(){return 'world';}  
                

                 

                FWIW

                 

                Loic

                1 person found this helpful