So the script I've written will move pages if they meet a certain bookmark name to the bottom of the file. I have a problem though, because I want to do it in a certain order. If I repeat the process then the "count" will be off because pages have already been moved. So I'm really stuck. Note: I don't want to cycle through the entire array of names at the same time, so that I can define an order.
var number = new Array();
var k=0;
var bknames = new Array ();
function DumpBookmark(bkm, nLevel)
{
var s = "";
for (var i = 0; i < nLevel; i++) s += " ";
if (bkm.name != "Root") {
bkm.execute();
number[k] = this.pageNum;
bknames[k] = bkm.name;
k++;
}
if (bkm.children != null)
for (var i = 0; i < bkm.children.length; i++)
DumpBookmark(bkm.children[i], nLevel + 1);
}
DumpBookmark(this.bookmarkRoot, 0);
var count=0;
var startpg=0;
var endpg=numPages-1;
var trigger =0;
var ss = new Array ();
ss[0] = "blahblah";
ss[1] = "blahblah";
ss[2] = "blahblah";
function test(c, count) {
for (var n = 0; n < numPages; n++){
for (i = 0; i<=k; i++) {
if (number[i] == n) {
for ( var r=c; r < c+1; r++) {
if (bknames[i] == ss[r]) {
startpg = number[i];
for (var y = (startpg+1); y < numPages; y++){
for (var x = 0; x<=k; x++){
if (number[x] == y) {endpg=number[x]-1; x=k; y=numPages; trigger=1;}
if (trigger==0) {endpg = numPages-1; }
}
}
endpg= endpg - count;
startpg= startpg - count;
app.alert("Start = " + startpg + " and End = " + endpg, 3);
for (z=0; z < (endpg-startpg)+1; z++) {
this.movePage(startpg,this.numPages - 1);
}
count++;
count = count + endpg - startpg;
trigger=0;}}}}}}
}
test(0,0);
test(1,0);
etc...
How should the count be modified each cycle?
Bookmark 1 is on pg 1
Bookmark 2 is on pg 5.
The program will drop pages 1-4 to the bottom, assuming "Bookmark 1" is on my list of bookmarks to drop.