Copy link to clipboard
Copied
Paraphrasing Shakepeare's Hamlet, I wonder what this parameter of t he Find method is all about:
FDK reference states:
FS_FindWrap A BoolT flag that determines whether the find operation will wrap when it reaches the location where the search began.
In FMfindReplace I have this defintion for the Find parameters:
oPropVal1 = new PropVal() ; /
oPropVal1.propIdent.num = Constants.FS_FindWrap ;
oPropVal1.propVal.valType = Constants.FT_Integer;
oPropVal1.propVal.ival = 0 ; // no wrap
findParms.push(oPropVal1);
But this obviously has no no effect.
There was ample discussion on this 10 years ago: Telling Find method NOT to wrap
Rick makes the proposal «Before each find, try setting the document's TextSelection property to the TextLoc you want to start the search from».
But I have no idea how to follow this advice, because the result of the find is a new text location...
So the question remains:
How to stop searching after the last find in a document?
Edit
The problem becomes cumbersome when searching in a book.
It will be darn difficult to make my script do the right thing: observe the end of the document and then go to the next one, if the user presses just Find, Find, ... until he finds the desired environment of his search term.
One more strangeness with this property:
When I leave out the setting of the Wrap parameter to 0 (→ do not wrap) in the function GetFindParameters the while in the snippet will not come to an end. Hence at least for searching Anchored Frames the wrap parameter works ...
Snippet from function CollectUserStrings:
oTRfound = oDoc.Find(oTL, oFindParms);
oFindParms = KLD_F.GetFindParameters ("ANCFRM", "", 0, false, false, false)
// (sType, sSearch, iMode, bWord, bCase, bBa
...
Copy link to clipboard
Copied
I would like to know that too, actually 🙂
Copy link to clipboard
Copied
I will try with the following procedure:
Edit
This method works (at least for text - need further tests), although my particular scripts demands certain detail definitions. The experience is not completely the same as with standard FM Find/Change - but it is transparent to the user, as i provide information in the panel about the status of the find.
Copy link to clipboard
Copied
At least one problem remains: I can not start the search with a hidden book compoent (invisible). In this case I do not get a selection, although I explicitly define
oTLstart = new TextLoc (oDoc.FirstPgfInDoc, 0);
And I leave the traversed documents open. Well, this may be a disadvantage for laarge books with many components. Will try to fix this until "release".
Copy link to clipboard
Copied
One more strangeness with this property:
When I leave out the setting of the Wrap parameter to 0 (→ do not wrap) in the function GetFindParameters the while in the snippet will not come to an end. Hence at least for searching Anchored Frames the wrap parameter works ...
Snippet from function CollectUserStrings:
oTRfound = oDoc.Find(oTL, oFindParms);
oFindParms = KLD_F.GetFindParameters ("ANCFRM", "", 0, false, false, false)
// (sType, sSearch, iMode, bWord, bCase, bBack)
while (oTRfound.beg.obj.ObjectValid()) {
oFrameTI = oDoc.GetTextForRange (oTRfound, Constants.FTI_FrameAnchor);
for (k = 0; k < oFrameTI.length; k++) {
oTextItem = oFrameTI[k];
oObject = oTextItem.obj;
sFound = oObject.UserString;
oTL = oObject.TextLoc;
oUstring = new KLD_F.UserString("AFrame", oObject, sFound, oTL);
aoUserStrings.push (oUstring);
}
oTRfound = oDoc.Find(oTL, oFindParms);
}
Therefore in my script FMfindRepl I have both set the "noWrap" parameter (for situation like the one above) and check in other situations with the function IsWrapped whether I'm back to start of the find sequence or not...