is that true, that if text area for Find() is an array element, i.e.:
myStory = SomeStory.texts
then mFound.length always is 1, and
if something is found ==> mFound.length > 0 has to be checked?
... and why?
Your sample code both uses mFound and myFound. Just a typo?
Thanks for your observation and sorry for my carelessness, but yes - there is a typo.
Found result variable length ==1. It 1st element length == 0 and it is not a text
Now to your question:
1) Usually, myArea.findText() will return an Array of zero, one or more Text objects. In other words, provided that myFound.length > 0, each myFound[i] should be a Text specifier. This is what happens if myArea is the Application, a Document, a Story, or any singular Text specifier.
2) BUT, if for some reason myArea is a plural specifier—such as myStory.paragraphs.everyItem()—then myArea.findText() will return an Array of Array(s) of Text(s). The outer array reflects the plural behavior of the specifier, while the inner arrays reflect the return type of the findText() method. In that case you may have empty arrays within the outer array. Indeed:
will send the findText() command to every paragraph, so any paragraph that does not match the query will produce an empty array.
Maybe your script leads to something similar. We'd need to see more code to figure it out.
Thanks Marc for your explanation!
It is that, indeed!