Quantcast
Channel: Adobe Community: Message List - InDesign Scripting
Viewing all articles
Browse latest Browse all 37788

Re: It is possible to script a decimal approximation in Indesign?

$
0
0

You might want to change the changeWhat grep depending on exactly what numbers you want to find but this is the basic idea to round all numbers with a "," instead of a "."

 

 

var doc = app.activeDocument;
app.changeGrepPreferences = app.findGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\d+\,\\d+";
var myNumberFinds = doc.findGrep(),      l = myNumberFinds.length;while (l--)    {        app.changeGrepPreferences.changeTo = Math.round(myNumberFinds[l].contents.replace(/\,/,".")).toString();        myNumberFinds[l].changeGrep();    } 

 

If you want to change numbers that have at least 1 but not more than 2 whole numbers then a comma then at least 1 and at most 2 fractional numbers then you could use for your find what line

app.findGrepPreferences.findWhat = "(?<=\\D)\\d{1,2},\\d{1,2}(?=\\D)";

That is providing that the story does not start or end with the number to be changed.


Viewing all articles
Browse latest Browse all 37788

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>