7 Replies Latest reply on Jul 1, 2013 7:55 AM by rajnikids

    %tage of completion in progression bar

    rajnikids Level 1

      Hi Forum,

       

      I do have a doubt about getting "percentage of completion in progress bar", while progress bar is running.

       

      I'm trying to find the completed percentage of myFound(); in progression bar.

       

      Could anybody help on this..

       

      app.findTextPreferences.findWhat = "INSTRUCTION NOT PROVIDED"

      app.changeTextPreferences.changeTo = "Rajni";

      app.changeText();

      var Tf = app.changeText();

       

      var list = [Tf];

      var w = new Window ("palette");

      var progress = progress_bar (w, list.length);

      for (var i = 0; i < list.length; i++)

      {

      progress.value = i+1;

      // user functions

      $.sleep (400);

      }

      progress.parent.close();

      function progress_bar (w, stop)

      {

      var pbar = w.add ("progressbar", undefined, 1, stop);

      pbar.preferredSize = [300,20];

      w.show (list);

      return pbar;

      }

       

      Also when adding the progression script inside the find loop, the find and change task is getting delayed.

       

      thanks

      rkids.

        • 1. Re: %tage of completion in progression bar
          Jump_Over Level 5

          Hi,

           

          Looks like your list.length is always == 0 (app.changeText() called twice)

          I am afraid you can't display a progress of method ( changeText() ) using progressbar.

           

          However you could try this;

           

           

          app.findTextPreferences.findWhat = "INSTRUCTION NOT PROVIDED";
          
          var myDoc =  app.activeDocument,
               mFound = myDoc.findText(),
               currText,
               progressWin = new Window ("palette", "" , [50, 150, 384, 240]),
               progressBar = progressWin.add ("progressbar", [12, 12, 312, 32], 0, mFound.length -1),
               mText = progressWin.add("statictext",[12, 52, 312, 72], "1 element of " + mFound.length);
          
          
          progressWin.show();
          
          for ( var count = 1; count <= mFound.length; count ++) {
               progressBar.value = count ;
               mText.text = count + " element of " + mFound.length;
               currText = mFound[count-1];
               currText.select();
               currText.showText();
               $.sleep(300);
               currText.contents = "Rajni";
               $.sleep(700);
               }
          
          app.findTextPreferences = null;
          progressWin.close();
          

           

          rgds

          Jarek

          • 2. Re: %tage of completion in progression bar
            rajnikids Level 1

            Hello Jarek,

             

            Thanks so much for the edits.

             

            Actually my try is to copy the files from a folder and paste it to another.

            so, im going to define the path of copyfolder and paste folder in Script UI dialog box.

             

            when copy button is cliked, it will automatically paste the copied into the defined path viceversa for paste option also.

             

            so, could i be able to do this by altering the above reply.

             

            and thanks for the quick reply Jarek.

            • 3. Re: %tage of completion in progression bar
              rajnikids Level 1

              Hi Jarek,

               

              I have just modified your valuable worthy one, like this.

               

              I'm  wondering, If i'm right.

               

              I'm adjusting the sleep time from 700 to 100, assuming, I  could get the Real speed while finding and changing the text.

               

              Because fixing 700 as a sleep time, makes the find and change function slower.

               

              Correct me, if I'm wrong!. Advice me, how could i get the real speed time when using progree bar method.

               

              app.findTextPreferences.findWhat = "INSTRUCTION NOT PROVIDED";

               

              var myDoc =  app.activeDocument,

                   mFound = myDoc.findText(),

                   currText,

                   progressWin = new Window ("palette", "" , [50, 150, 384, 240]),

                   progressBar = progressWin.add ("progressbar", [12, 12, 312, 32], 0, mFound.length -1),

                   mText = progressWin.add("statictext",[12, 52, 312, 72]);

               

               

              progressWin.show();

               

              for ( var count = 1; count <= mFound.length; count ++) {

                   //progressBar.value = count ;

                   mText.text = "completed" + count/mFound.length*100 + " of 100%";

                   currText = mFound[count-1];

                   currText.select();

                   //currText.showText();

                   $.sleep(100);

                   currText.contents = "Rajni";

                  $.sleep(00);

                   }

               

              app.findTextPreferences = null;

              progressWin.close();

               

               

              many many thanks Jarek.

              • 4. Re: %tage of completion in progression bar
                Jump_Over Level 5

                Hi,

                 

                Assuming both folders are defined in some way...

                 

                myPath1 = "~/Desktop/testCFolder";     // another way to define?
                myPath2 = "~/Desktop/testPFolder";     // another way to define?
                mFolderToCopy = Folder(myPath1);
                mFolderToPaste = Folder(myPath2);
                if (!mFolderToCopy.exists || !mFolderToPaste.exists) 
                          {
                          alert ("No copy/paste folder found");
                          } else {
                          mFiles = mFolderToCopy.getFiles("*");     // mask files
                          action(mFiles, mFolderToPaste);
                          }
                
                
                function action (arr, destFolder) {
                     progressWin = new Window ("palette", "" , [50, 150, 384, 240]),
                     progressBar = progressWin.add ("progressbar", [12, 12, 312, 32], 0, arr.length -1),
                     progressText = progressWin.add("statictext",[12, 52, 312, 72], "copying started");
                          progressWin.show();
                          for ( var k = 0; k < arr.length; k++) {
                                    progressBar.value = k + 1;
                                    arr[k].copy(destFolder.fullName + "/" + arr[k].name);
                                    progressText.text = "copying file: " + arr[k].name + " (" + Math.round( (k+1)/arr.length*100 ) + " of 100%)";
                                    }
                          progressWin.close();
                          }
                

                 

                In case of $.sleep() ==> you dont need to use it in fact.

                It could be placed just for slow down the process and to let you see a progressBar window changes.

                No other reasons.

                 

                rgds

                Jarek

                • 5. Re: %tage of completion in progression bar
                  rajnikids Level 1

                  Hi Jarek,

                   

                  The golden and golden moments for me to see your valuable inputs again.

                   

                  So, I shouldn't  wait even a single minutes to say "its a fantastic magic of you". 

                   

                  Not will I, disturb you again, apart from this silly question.

                   

                  Jarek, can I have a suggestion to run this script, without the help of indesign script panel. A common place (desktop), where I can click and play this scrip "to copy and paste".

                   

                  Like Applescript, where I can, trigger the jsx script to start running. (I assume should be with help of Adobe bridge).

                   

                  Many Many Many thanks for the tremendous support and cleaned up my messy script.

                  • 6. Re: %tage of completion in progression bar
                    Jump_Over Level 5

                    Hi,

                     

                    Glad if can help you

                     

                    In case of run a script is not a straight effort to do it by clicking an icon.

                    However it could be this way:

                    - script is placed in Indesign Startup Folder;

                    - there is an user interaction window inside a script body to determine if InDesign should quit at the end of process;

                    - desktop shortcut icon is linked to InDesign app.

                     

                    ...If you still can see a benefits with opening ID app just to copy some files...

                     

                    rgds

                    Jarek

                    • 7. Re: %tage of completion in progression bar
                      rajnikids Level 1

                      wah! Jarek! wah!.

                       

                      Excellent help continously during the course of this short time.

                       

                      Admiring the way you have answered so far.

                       

                      The additional benefit should goes to you, if I can have an additional offer,  to  tick the "correct answer" once again..

                       

                      By words, 100 points to you Jarek,

                       

                      Thanks so much for the effort, have help me.

                       

                      Rajni.