Copy link to clipboard
Copied
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
.contents; myNum = roundNumber (myNum);
};
app.findGrepPreferences = app.changeGrepPreferences = null;
function roundNumber (number)
{
number = Math.round(Number (number));
return number;
}
Thanks in advance!
(^/)
Anytime dear 🙂
tpk1982 I don't think Obi had a problem with that
Copy link to clipboard
Copied
Code given by Trevor, 3 years ago!
Re: It is possible to script a decimal approximation in Indesign?
Thanks Trevorׅ!
(^/)
var myDoc = app.activeDocument;
app.findGrepPreferences = app.changeGrepPreferences = null;
app.findGrepPreferences.findWhat = "\\d+\\.\\d+";
var myFound = myDoc.findGrep();
n = myFound.length;
while (n--)
{
app.changeGrepPreferences.changeTo = Math.round(myFound
.contents).toString(); myFound
.changeGrep(); }
app.findGrepPreferences = app.changeGrepPreferences = null;
Copy link to clipboard
Copied
I think changeGrep() is missing in your code..
Copy link to clipboard
Copied
Anytime dear 🙂
tpk1982 I don't think Obi had a problem with that