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

Re: How to write data at the end of doc in reverse order?[CS6-jsx]

$
0
0

Yes, .reverse() method helped:

 

var mStory = app.selection[0].insertionPoints[0].parentStory;

var aEndList = []; // prepare array

mFind ="\\{\\{\\{.+?\\}\\}\\}"; // my coding of text being searched (kinda {{{some needed text}}})

   app.findGrepPreferences = app.changeGrepPreferences = NothingEnum.nothing;

    app.findChangeGrepOptions.includeFootnotes = false;

    app.findGrepPreferences.findWhat = mFind;

 

var mFound = mStory.findGrep();

$.writeln(mFound.length);

for (i = mFound.length-1; i>=0; i--){

mSel = mFound[i];

mStr_tmp  = String(i+1) + ". " + mFound[i].contents; //temporary string with added number

mSel.select();

app.selection[0].remove();

 

//place number of refer instead of refer itself in text

mSel.insertionPoints[0].texts[0].position = Position.SUPERSCRIPT;

mSel.insertionPoints[0].texts[0].contents = String(i+1);

aEndList.push(mStr_tmp);

}

 

aEndList.reverse();

myString = aEndList.join ("\r");

//place resorted and numbered list

mStory.insertionPoints.item(-1).select();

mStory.insertionPoints.item(-1).contents = myString;

 

But the problem arose. Operating with contents looses text formatting. So i used cut-paste method. can i keep formattin by some way in this code?


Viewing all articles
Browse latest Browse all 37788

Trending Articles



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