Copy link to clipboard
Copied
With assistance of forum's Frame Master I've be able to implement the code below to search for regexps. However, I can't seem to set the Consider Case parameter. I remember an earlier piece of code posted by K. Daube that used qFlags, but I'm not familiar with how they work. Rick mentioned adding an "ig" or "g" to set the global flag at the end of the experession, but it seems to just stip that off when I try passing that to the function. Thoughts?
regex = "Widget";
getRegexFindParams (regex)
function getRegexFindParams (regex) { //CP.getRegexFindParams = function (regex) {
doc=app.ActiveDoc;
docStart = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;
tloc = new TextLoc (docStart, 0);
findParams = new PropVals ();
propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindText;
propVal.propVal.valType = Constants.FT_String;
propVal.propVal.sval = regex;
findParams[0] = propVal;
propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindCustomizationFlags;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival = 16; // Regular expressions
findParams[1] = propVal;
propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_FindWrap;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival=0;
findParams[2] = propVal;
propVal = new PropVal ();
propVal.propIdent.num = Constants.FS_RegexFlavour;
propVal.propVal.valType = Constants.FT_Integer;
propVal.propVal.ival = 1;
findParams[3] = propVal;
foundText = doc.Find(tloc, findParams);
//background highlight found text and get next
The customisation flags must be "ored". The following snippet may help you (bWord is true if only full words are to be considere, bCase etc. analogous):
if (bWord || bCase || bBack || bRegEx || bWild) {
oPropVal3 = new PropVal() ;
oPropVal3.propIdent.num = Constants.FS_FindCustomizationFlags ;
oPropVal3.propVal.valType = Constants.FT_Integer;
qFlags = 0;
if (bCase) { qFlags = qFlags | Constants.FF_FIND_CONSIDER_CASE;} // 0x01
if (bRegEx) { qFlags = qFlags | Consta
...
Copy link to clipboard
Copied
The customisation flags must be "ored". The following snippet may help you (bWord is true if only full words are to be considere, bCase etc. analogous):
if (bWord || bCase || bBack || bRegEx || bWild) {
oPropVal3 = new PropVal() ;
oPropVal3.propIdent.num = Constants.FS_FindCustomizationFlags ;
oPropVal3.propVal.valType = Constants.FT_Integer;
qFlags = 0;
if (bCase) { qFlags = qFlags | Constants.FF_FIND_CONSIDER_CASE;} // 0x01
if (bRegEx) { qFlags = qFlags | Constants.FF_FIND_USE_REGEX; // 0x10
oPropVal4 = new PropVal ();
oPropVal4.propIdent.num = Constants.FS_RegexFlavour; // 17
oPropVal4.propVal.valType = Constants.FT_Integer;
oPropVal4.propVal.ival = Constants.FR_USE_PERL; // 1
findParms.push(oPropVal4);
} else {
if (bWild) { qFlags = qFlags | Constants.FF_FIND_USE_WILDCARDS;} // 0x04
if (bWord) { qFlags = qFlags | Constants.FF_FIND_WHOLE_WORD;} // 0x02
if (bBack) { qFlags = qFlags | Constants.FF_FIND_BACKWARDS;} // 0x08
}
oPropVal3.propVal.ival = qFlags; // qFlags OK; ...ival reports error in ESTK
findParms.push(oPropVal3);
Copy link to clipboard
Copied
Sorry...disregard my previous. I see you already provide me the answer. I had forgotten this post.