Copy link to clipboard
Copied
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
You are not allocating your find parameters just right. Try this and it should work for you.
findParams = AllocatePropVals(1);
findParams[0].propIdent.num = Constants.FS_FindText;
findParams[0].propVal.valType = Constants.FT_String;
findParams[0].propVal.sval = "Example";
Rick Quatro
FrameMaker 10 ExtendScript: Scripting Strategies
Copy link to clipboard
Copied
You are not allocating your find parameters just right. Try this and it should work for you.
findParams = AllocatePropVals(1);
findParams[0].propIdent.num = Constants.FS_FindText;
findParams[0].propVal.valType = Constants.FT_String;
findParams[0].propVal.sval = "Example";
Rick Quatro
FrameMaker 10 ExtendScript: Scripting Strategies
Copy link to clipboard
Copied
Yes, that worked. Thank you very much. And while I'm thanking you, the sample scripts from your last seminar have also been very useful, too.