Double and above space change into single space


hi all,

 

i beginner in scripting. using cs3 scripting tutorial learn script.

 

today task in document want change double , above spaces single space using for loop.


my script  follows:

 

 

var mydocument = app.activedocument;

 

app.findtextpreferences.findwhat = "nothingenum.nothing";

app.changetextpreferences.changeto = "nothingenum.nothing";

 

app.findtextpreferences.findwhat = "  ";

app.changetextpreferences.changeto = " ";

app.activedocument.changetext();

 

var myfind = mydocument.findtext(true);

 

for(i=0; i<myfind.length; i++){

    //alert(i)  /* think line need*/

    }

 

 

can me run program program succesfully.

much easier approach use grep.

 

try this:

 

app.findgreppreferences = app.changegreppreferences = null; app.findgreppreferences.findwhat = "[~m~>~f~|~s~s~<~/~.~3~4~% ]{2,}"; app.changegreppreferences.changeto = "\\s"; app.activedocument.changegrep(); app.findgreppreferences = app.changegreppreferences = null; 

 

hope helps.

 

--

marijan (tomaxxi)

http://tomaxxi.com



More discussions in InDesign Scripting


adobe

Comments