Highlighted

How to avoid wrap in find method ?

Advocate ,
Dec 14, 2016

Copy link to clipboard

Copied

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?

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

TOPICS
Scripting

Views

338

Likes

Translate

Translate

Report

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

How to avoid wrap in find method ?

Advocate ,
Dec 14, 2016

Copy link to clipboard

Copied

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?

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

TOPICS
Scripting

Views

339

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Dec 14, 2016 0
Enthusiast ,
Dec 14, 2016

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 14, 2016 0
K.Daube LATEST
Advocate ,
Dec 14, 2016

Copy link to clipboard

Copied

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

Thank You, Klaus!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Dec 14, 2016 0