Skip to main content
K.Daube
Community Expert
Community Expert
December 14, 2016
Answered

How to avoid wrap in find method ?

  • December 14, 2016
  • 1 reply
  • 630 views

Dear friends,

Although i carefully followed the advice found at this post, I have no success. The find always wraps back to the first occurrence fo the items to be found.

Case 3 works fine for several months now - but why does case 4 not?

Jang obviously had the same problem in the mentioned post ...

function GetFindParameters (iType, sSearch) {
var propVal, findParams = new PropVals() ; 

  switch (iType) {

// ...

    case 3: // ---------------------------------- find marker of type sSearch, don't wrap
      propVal = new PropVal() ; 
      propVal.propIdent.num = Constants.FS_FindWrap ; 
      propVal.propVal.valType = Constants.FT_Integer; 
      propVal.propVal.ival = 0 ;
      findParams.push(propVal); 
      propVal = new PropVal() ; 
      propVal.propIdent.num = Constants.FS_FindMarkerOfType; 
      propVal.propVal.valType = Constants.FT_String; 
      propVal.propVal.sval = sSearch; 
      findParams.push(propVal); 
      return findParams;
      break;

    case 4: // ---------------------------------- find character format sSearch, don't wrap
      propVal = new PropVal() ; 
      propVal.propIdent.num = Constants.FS_FindWrap ; 
      propVal.propVal.valType = Constants.FT_Integer; 
      propVal.propVal.ival = 0 ;
      findParams.push(propVal); 
      propVal.propIdent.num = Constants.FS_FindCharTag; 
      propVal.propVal.valType = Constants.FO_CharFmt; 
      propVal.propVal.sval = sSearch; 
      findParams.push(propVal); 
      return findParams;
      break;

    default:
      alert ("GetFindParameters:\nPgm error: case " + iType + " in switch not defined.", "GetFindParameters", true);
      return null;
  }
} //---  end GetFindParameters

Because of this my searches are not terminated and loop forever - FA_errno is not set (as described in the FDK doc).

  findRange = goCurrentDoc.Find  (oTextLoc, findParams);// finds text range (object pgf), lenght 1
  if (FA_errno === Constants.FE_NotFound) {
    return null;                                  // no further items
  }

What's wrong with my search parameters?

This topic has been closed for replies.
Correct answer Klaus Göbel

Hi Klaus,

in case 4 you are overriding "propVal.propVal.valType" (line 21) with line 25.

I think you forgot "propVal = new PropVal() ; " Insert after line 23

1 reply

Klaus Göbel
Klaus GöbelCorrect answer
Legend
December 14, 2016

Hi Klaus,

in case 4 you are overriding "propVal.propVal.valType" (line 21) with line 25.

I think you forgot "propVal = new PropVal() ; " Insert after line 23

K.Daube
Community Expert
K.DaubeCommunity ExpertAuthor
Community Expert
December 14, 2016

As usual: to close to the screen the overview is lost...

Thank You, Klaus!