[Framers] ExtendScript does not set Property ival

Klaus Daube klaus at daube.ch
Wed Dec 9 03:43:37 PST 2020


Sorry folks, the whole issue is a Hornberger Schiessen (wild goose chase):

The error messages in the Data Browser are irrelevant for the positive result. The 
script successfully finds 1st, 2nd, 4th and 5th and refuses to find 3Rd - hence RegEx 
search is OK and Consider Case is observed:

/*Test_MiniFind.jsx ====== UTF-8 ==========================================
              Test for the functions GetFindParameters, FindSomething
History       2020-12-09
*/ ; // ===================================================================
//#target framemaker
//@target framemaker

function GetFindParameters (sSearch) { //======================
//           Set up a text find with case sensitive RegEx
var findParms, qFlags, oPropVal1, oPropVal2, oPropVal3; 

  findParms = new PropVals();
  oPropVal1 = new PropVal() ;  
    oPropVal1.propIdent.num = Constants.FS_FindText;  
    oPropVal1.propVal.valType = Constants.FT_String;  
    oPropVal1.propVal.sval = sSearch;  
  findParms.push(oPropVal1);  

  oPropVal2 = new PropVal() ;  
    oPropVal2.propIdent.num = Constants.FS_FindCustomizationFlags ;  
    oPropVal2.propVal.valType = Constants.FT_Integer; 
    qFlags = 0; 
    qFlags = qFlags   | Constants.FF_FIND_CONSIDER_CASE; // 0x01
    qFlags = qFlags   | Constants.FF_FIND_USE_REGEX;     // 0x10
    oPropVal2.propVal.ival = qFlags;                     // 
  findParms.push(oPropVal2);  

  oPropVal3 = new PropVal ();  
    oPropVal3.propIdent.num = Constants.FS_RegexFlavour;  
    oPropVal3.propVal.valType = Constants.FT_Integer;  
    oPropVal3.propVal.ival = Constants.FR_USE_PERL;      // 1
    findParms.push(oPropVal3);  

//$.bp(true);   // check oPropVal2 and oPropVal3 - ival reports errors...
  return findParms;
} //---  end GetFindParameters -------------------------------------------------

function FindSomething (oDoc, sSearch) { // ===============================
var oFindParms, oTR, oTRsaved ;

  oTRsaved = oDoc.TextSelection;                  // we may need to come back
  oTR = oDoc.TextSelection;                       // start from current location

  oFindParms = GetFindParameters (sSearch); 
  if (oFindParms === null) {return undefined;}    // oTR has not changed yet
  oTR = oDoc.Find(oTR.beg, oFindParms);
  if (FA_errno === Constants.FE_Success) {        // 0: FE_Success; -95: FE_NotFound
    oDoc.TextSelection = oTR;                     // selection visible ? 
    oDoc.ScrollToText(oTR);                       // selection visible ? Yes
    return oTR;
  } else {                                        // Not found
    oDoc.TextSelection = oTRsaved;
    oDoc.ScrollToText(oTRsaved);
    return undefined;
  }
} //---  end FindSomething ------------------------------------------------

function main () { // =====================================================
// testfile: E:\_DDDprojects\_JSX-library\TestFiles\Gugus-file1.fm 
//           ontains 1st, 2nd, 3Rd, 4th, 5th 
var oDoc = app.ActiveDoc, OK, oTR;

 oTR = FindSomething (oDoc, "\\d[st|nd|rd|th]");  // text by regex

if (oTR == undefined) {
    Alert ("not found");
  }
} //--- end main ----------------------------------------------------------

main ();

I do not know yet why my initial script did not work - have to take a very close look 
to the differences to this working script.

Thnaks for Your patience
Klaus
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Klaus Daube             Phone:  +41-44-381 37 77
Schäracher 11           Mail:   klaus at daube.ch
CH-8053 Zürich          Web:    www.daube.ch




More information about the Framers mailing list