Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
0

Using Find() in ExtendScript

Guest
Jun 10, 2011 Jun 10, 2011

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

TOPICS
Scripting
2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 10, 2011 Jun 10, 2011

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

https://www1.gotomeeting.com/register/278546009

Translate
Community Expert ,
Jun 10, 2011 Jun 10, 2011

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

https://www1.gotomeeting.com/register/278546009

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jun 10, 2011 Jun 10, 2011
LATEST

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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines