3 Replies Latest reply on Nov 2, 2016 3:02 PM by Trevorׅ

    Code to be evaluated! [004] // Round numbers! …

    Obi-wan Kenobi Adobe Community Professional

      Hi all scripters,

       

      Something is wrong: I can't find the way (surely obvious) to replace my numbers by their rounded values!! 

       

       

      var myDoc = app.activeDocument;  
      app.findGrepPreferences = app.changeGrepPreferences = null;
      app.findGrepPreferences.findWhat = "\\d+\\.\\d+";
      var myFound = myDoc.findGrep();
      
      
      for (n = 0; n < myFound.length; n++){
              var myNum = myFound[n].contents;
              myNum = roundNumber (myNum);
      };
      
      
      app.findGrepPreferences = app.changeGrepPreferences = null;
      
      
      function roundNumber (number)  
          {  
          number = Math.round(Number (number));  
          return number;  
          }
      

       

       

      Thanks in advance!

       

      (^/)