Quantcast
Channel: Adobe Community : Popular Discussions - InDesign Scripting
Viewing all articles
Browse latest Browse all 15932

insert or replace last content

$
0
0

HI Forum,

 

I do need a little tweak on this script...

 

Thing is, i want to find the last paragraph, last line, last character and make it as full stop...

eg.

•   can do anything if you need;  (";" to replace with ".").

 

it is doing that,,,

 

but if there is no ";" or ":" it is replacing the character d....

 

I want check the last character is ";" or ":" and to replace with "."

 

if there is no ";" or ":" just add "." at the end..

 

 

myDoc = app.activeDocument;

 

app.findGrepPreferences = null;

app.findGrepPreferences.bulletsAndNumberingListType = ListType.BULLET_LIST;

var myResults = app.findGrep();

var oDoc = app.activeDocument;

 

for(n=0; n< myResults.length;n++){

var fnd = myResults[n].paragraphs.lastItem().lines.lastItem();

   

               if(fnd.insertionPoints.itemByRange(-3,-2).contents !== "."){

               fnd.insertionPoints.itemByRange(-3,-2).contents = "."

           

alert(fnd.insertionPoints.itemByRange(-3,-2).contents)

}

 

}

 

 

Many thanks...


Viewing all articles
Browse latest Browse all 15932

Trending Articles



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