12 Replies Latest reply on Feb 27, 2016 1:15 PM by TᴀW

    CC2015 Refresh Progress Bar

    grg79 Level 1

      Hi

       

      I read several post about the subject....

       

      Why a simple script with a progress bar don't display/refresh progress bar?

      Only  CC-CC2015.

      CS5-CS6 work fine

       

      #targetengine "progress2"
      
      
      app.scriptPreferences.enableRedraw = true
      
      
      
      
      var found = new Array (50);
      var w = new Window ('palette');
      w.pbar = w.add ('progressbar', undefined, 0, found.length); w.pbar.preferredSize.width = 300;
      w.show();
      for (var i = 0; i < found.length; i++){ w.pbar.value = i+1;
      $.sleep(20); // Do something useful here
      }
      
      
      
      
           
      
      
      

       

       

      More complex script.... same problem.... don't display/refresh the window.

       

      #targetengine "progress"
      
      
      app.scriptPreferences.enableRedraw = true
      
      
      function ProgressBar(/*str*/title, /*uint*/width, /*uint*/height)  
      // =========================================================  
      // Version 2.beta | 12-Nov-2014  
      // -- Keep the message centered --see below the new method this.msg()  
      // -- Supports message patterns e.g: "Step %1/100" --see the sample code  
      // -- Other minor improvements  
      // =========================================================  
      {  
          (60<=(width||0))||(width=340);  
          (40<=(height||0))||(height=60);  
        
          var H = 22,  
              Y = (3*height-2*H)>>2,  
              W = new Window('palette', ' '+title, [0,0,width,height]),  
              P = W.add('progressbar', { x:20, y:height>>2, width:width-40, height:12 }, 0,100),  
              T = W.add('statictext' , { x:0, y:Y, width:width, height:H }),  
              __ = function(a,b){ return localize.apply(null,a.concat(b)) };  
        
          this.pattern = ['%1'];  
        
          W.center();  
        
          // ---  
          // API  
          // ---  
           
          this.msg = function(/*str*/s)  
          // ---------------------------------  
          {  
              s && (T.location = [(width-T.graphics.measureString(s)[0])>>1, Y]);  
              T.text = s;  
          };  
        
          this.show = this.reset = function(/*str*/s, /*uint*/v)  
          // ---------------------------------  
          {  
              if( s && s != localize(s,1,2,3,4,5,6,7,8,9) )  
                  {  
                  this.pattern[0] = s;  
                  s = __(this.pattern, [].slice.call(arguments,2));  
                  }  
              else  
                  {  
                  this.pattern[0] = '%1';  
                  }  
               
              P.value = 0;  
              P.maxvalue = v||0;  
              P.visible = !!v;  
        
              this.msg(s);  
              W.show();  
          };  
        
          this.hit = function(x)  
          // ---------------------------------  
          {  
              ++P.value;  
              ('undefined' != typeof x) && this.msg(__(this.pattern, [].slice.call(arguments,0)));  
          };  
        
          this.hide = function()  
          // ---------------------------------  
          {  
              W.hide();  
          };  
           
          this.close = function()  
          // ---------------------------------  
          {  
              W.close();  
          };  
      };  
        
        
      //------------------------------------------------  
      //      SAMPLE CODE  
      //------------------------------------------------  
        
      (function()  
      {  
          var PB = new ProgressBar("Script Title",350,100),  
              i, vMax;  
        
          // Quick process  
          // ---  
          PB.show("Processing quickly... %1 / 500", vMax=500, i=0);  
          for( ; i < vMax ; $.sleep(8), PB.hit(++i) );  
           
          PB.reset("Wait for 800 ms...");  
          $.sleep(800);  
        
          // Slow process  
          // ---  
          PB.reset("And now slowly (%1%)  |  Stage %2", vMax=13, 0, i=0);  
          for( ; i < vMax ; ++i, PB.hit((100*(i/vMax)).toFixed(2), i), $.sleep(400+200*(.5-Math.random())) );  
        
          $.sleep(500);  
          PB.msg("The job is done.");  
          $.sleep(1500);  
        
          // Quit  
          // ---  
          PB.close();  
      })();  
      
      
      
      
      
      

       

       

      Thanks