Quantcast
Channel: Adobe Community: Message List
Viewing all articles
Browse latest Browse all 142955

Re: Re: Re: Re: Why mFound = mTarget.findGrep() not work on cs5.5?

$
0
0

Hi Uwe,

 

Thanks for pointing out the typos and omissions.

 

app.documents.everyItem().masterSpreads.everyItem().allPageItems

 

creates a simple array of arrays: [array1, array2, array3, . . .], so that's easy to flatten using concat. Flattening arrays with any depth of nesting isn't too complicated: it follows the same idea as traversing any kind of structure such as subdirectories, indexes, xml trees:

 

function flatten (inArray, outArray) {    for (var i = 0; i < inArray.length; i++) {        if (inArray[i] instanceof Array) {            flatten (inArray[i], outArray);        } else {            outArray.push (inArray[i]);        }    }    return outArray;
}

 

Call the function like this:

 

myArray = [1,2,[3,4,['a','b','c'],5],6,7];

flattened = flatten (myArray, []);

 

Your approach of looking only in master pages may be quicker in long documents, but it's much more complicated than my second approach, which simply finds everything and then filters out what's not on a master page.

 

Peter


Viewing all articles
Browse latest Browse all 142955

Trending Articles



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