Using Find() in ExtendScript
As I'm sure anyone who has started working with ExtendScript in FM10 knows, the existing documentation is still pretty thin. Most of what I've learned has been adapted from the FDK Guide & Reference docs, mostly by trial and error. I've run up against one problem that has me pretty stumped, though, and I don't know if I'm doing something wrong, or if I've run into a bug. I would appreciate any insights.
I've been trying to use the Find() method. I've got it running (as in, without throwing an error), but it isn't producing a usable result. Regardless of whether I search for text that is in the document, or text that isn't, the script returns an empty TextRange object, but FA_Errno is set to FE_Success.
This is the code I'm using:
var thisDoc = app.ActiveDoc;
var docStart = thisDoc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf ;
var tloc = new TextLoc(docStart,0);
findParams = AllocatePropVals(1);
findParams[0].propIdent.ival = Constants.FS_FindText;
findParams[0].propVal.sval = "Example";
foundText = thisDoc.Find(tloc, findParams);
testText = thisDoc.GetTextForRange(foundText, Constants.FTI_String);
alert(testText.length); // Always returns 0
PrintFAErrno(); // Always prints "FE_Success" to console
