Hi Hunter (?)
I tried out your code on FM11 and it worked great! So you have no problems!
In all seriousness, I did try it and it worked fine and I was not surprised, because it looks fine. I placed three instances of the string into a document and it found them as expected. I added this to your code after " //do stuff to found text" to visually verify:
doc.TextSelection = foundText;
doc.ScrollToText (foundText);
if(!confirm("Keep going?")) return;
So the obvious question is... are you absolutely sure? Are you doing something to the text after you find it, something that might whack out the paragraph structures/offsets/etc. that confuses the search?
A couple of other notes:
I don't think you need both of these lines, although they work:
tloc = new TextLoc(foundText.end.obj, foundText.end.offset + 1);
foundText = doc.Find(tloc, findParams);
I think this line will suffice instead:
foundText = doc.Find(foundText.end, findParams);
Also, I augmented the find parameters so that it stops after the last match:
findParams = AllocatePropVals(2);
findParams[0].propIdent.num = Constants.FS_FindText;
findParams[0].propVal.valType = Constants.FT_String;
findParams[0].propVal.sval = searchString;
findParams[1].propIdent.num = Constants.FS_FindWrap;
findParams[1].propVal.valType = Constants.FT_Integer;
findParams[1].propVal.ival = false;
With that, you have to add another conditional to the while():
while (foundText.beg.obj.ObjectValid() && FA_errno == Constants.FE_Success) {
Let me know what you think about all this. I'm sure there is a solution here and it probably isn't too complex.
Russ
Message was edited by: Russ Ward (Accidentally submitted too soon!)