I am fresher for javascript


hi all,

 

this first script me. run but, think contains many lines. want sort few lines. please give alter solution me below script.

 

 

app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "tx";
app.changetextpreferences.appliedparagraphstyle = "tx2";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "ul";
app.changetextpreferences.appliedparagraphstyle = "unl";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "compinstrux";
app.changetextpreferences.appliedparagraphstyle = "figure";
app.documents.item(0).changetext();   
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;
app.findgreppreferences.appliedcharacterstyle = "h3";
app.findgreppreferences.findwhat = "(.+)";
app.changegreppreferences.appliedcharacterstyle = "h3";
app.changegreppreferences.changeto = "$0~>";
app.documents.item(0).changegrep();
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.findwhat = "^> ";
app.changetextpreferences.changeto = "^>";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.findwhat = " ^>";
app.changetextpreferences.changeto = "^>";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "h1";
app.changetextpreferences.appliedparagraphstyle = "h1";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "h2";
app.changetextpreferences.appliedparagraphstyle = "h2";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "ktx";
app.changetextpreferences.appliedparagraphstyle = "ktx";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "bleoc";
app.changetextpreferences.appliedparagraphstyle = "bleoc";
app.documents.item(0).changetext();
app.findtextpreferences = nothingenum.nothing;
app.changetextpreferences = nothingenum.nothing;
app.findtextpreferences.appliedparagraphstyle = "aleoc";
app.changetextpreferences.appliedparagraphstyle = "aleoc";
app.documents.item(0).changetext();
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;
app.findgreppreferences.appliedparagraphstyle = "objnl";
app.findgreppreferences.findwhat = "(\\d+)(\\.) ";
app.changegreppreferences.changeto = "\t$1$2\t";
app.documents.item(0).changegrep();
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;
app.findgreppreferences.appliedparagraphstyle = "nleoc";
app.findgreppreferences.findwhat = "(\\d+)(\\.) ";
app.changegreppreferences.changeto = "\t$1$2\t";
app.documents.item(0).changegrep();
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;
app.findgreppreferences.appliedparagraphstyle = "aleoc";
app.findgreppreferences.findwhat = "(.\\.) ";
app.changegreppreferences.changeto = "$1\t";
app.documents.item(0).changegrep();
app.findgreppreferences = nothingenum.nothing;
app.changegreppreferences = nothingenum.nothing;

 

 

 

 

 

regards

siraj

you need make function. use:

 

 

 

findgrep("find", "change", "findparagraphstyle", "findcharacterstyle", "changeparagraphstyle", "changecharacterstyle", "document")  function findgrep(find, change,fps,fcs,cps,ccs,d){ app.findgreppreferences = app.changegreppreferences = nothingenum.nothing; find != "find" ? app.findgreppreferences.findwhat = find : app.findgreppreferences.findwhat = nothingenum.nothing ; change != "change" ? app.changegreppreferences.changeto = change : app.changegreppreferences.changeto = nothingenum.nothing; fps != "findparagraphstyle" ? app.findgreppreferences.appliedparagraphstyle = mydoc.paragraphstyles.item(fps) : app.findgreppreferences.appliedparagraphstyle = nothingenum.nothing; fcs != "findcharacterstyle" ? app.findgreppreferences.appliedcharacterstyle = mydoc.characterstyles.item(fcs) : app.findgreppreferences.appliedcharacterstyle =nothingenum.nothing; cps != "changeparagraphstyle" ? app.changegreppreferences.appliedparagraphstyle = mydoc.paragraphstyles.item(cps) : app.changegreppreferences.appliedparagraphstyle = nothingenum.nothing; ccs != "changecharacterstyle" ? app.changegreppreferences.appliedcharacterstyle = mydoc.characterstyles.item(ccs) : app.changegreppreferences.appliedcharacterstyle = nothingenum.nothing; d != "document" ? d.changegrep() : app.activedocument.changegrep(); } 


More discussions in InDesign Scripting


adobe

Comments

Popular posts from this blog

How to decompile jsxbin to jsx

Gavik Photoslide GK2: Not able to upload photos - Joomla! Forum - community, help and support

Phoca Guestbook logger registret bruger af - Joomla! Forum - community, help and support