[Framers] ExtendScript does not set Property ival

Simon BUCH simon.buch at m-ais.com
Mon Dec 7 06:45:29 PST 2020


Hello,

I dabble in FrameMaker Extendscript, and I find it quite tricky to get 
right - especially when dealing with structured content.

The Find() statement has the syntax: Find(textLoc, findParams)
where textLoc is a TextLoc data type, and findParams is a PropVals data 
type.

The only times that I have played with PropVals is for file open 
operations which I find requires a fair bit of knowledge to get right.  
For example, if I want to open a file but ignore the 'missing fonts' 
errors, you need to get a property list index for the feature constant 
item, and then set the property value:
     var index, file, props, returnnp = new PropVals();
     props = GetOpenDefaultParams();
     //Ignore the "missing fonts" errors
     index = GetPropIndex(props, Constants.FS_FontNotFoundInCatalog);
     if (index > -1) props[index].propVal.ival = Constants.FV_DoOK;
     index = GetPropIndex(props, Constants.FS_FontNotFoundInDoc);
     if (index > -1) props[index].propVal.ival = Constants.FV_DoOK;
     file = Open(path, props, returnp);


So, I think you might have to find the property item, and then set the 
ival [integer value] and sval [string values] like this:
     var sProps = new PropVals(), flagCombo = 0, index ;
     index = GetPropIndex(sProps, Constants.FS_FindText)
     if (index > -1) sProp[index].propVal.sval = sSearch ;
     // don't wrap the search around to the top
     index = GetPropIndex(sProps, Constants.FS_FindWrap)
     if (index > -1) sProp[index].propVal.ival = false ;
     // set the appropriate flags
     index = GetPropIndex(sProps, Constant.FS_FindCustomizationFlags)
     if (bCase)  flagCombo |= Constants.FF_FIND_CONSIDER_CASE ;
     if (bRegEx) flagCombo |= Constants.FF_FIND_USE_REGEX;
     if (bWild)  flagCombo |= Constants.FF_FIND_USE_WILDCARDS;
     if (bWord)  flagCombo |= Constants.FF_FIND_WHOLE_WORD;
     if (bBack)  flagCombo |= Constants.FF_FIND_BACKWARDS;
     if (index > -1) sProp[index].propVal.ival = flagCombo
     // do the Find!
     Find(yourTextLoc, sProps)
     // don't forget to check the error code - just in case!


I hope this helps.

// Simon BUCH

On 07/12/2020 13:55, Klaus Daube wrote:
> Dear all
> My post on the FM Adobe forum
> (https://community.adobe.com/t5/framemaker/find-customisation-flags-not-accepted/td-p
> /11649459/) did not trigger any reaction so far:
> o Either the solution is so trivial that nobody wants to blame me
> o Or the problem is so nasty that nobody knows a solution to it.
>
> Test_GetFindParameters.jsx ====== UTF-8 ===========================
>                Test for the functions GetFindParameters, FindSomething
> History       2020-12-07
> */ ; // ==============================================================
> //#target framemaker
> //@target framemaker
>
> GetFindParameters ("\\d[st|nd|rd|th]");
>
> 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
>    return findParms;
> } //---  end GetFindParameters ---------------------------------------
>
> I do not get correct PropVals (an image doesn't make it into the forum, hence a
> retype of the Data Browser here):
>
> findParms = [object PropVal],[object PropVal],[object PropVal]
> oPropVal1 = [object PropVal]
>    propldent = [object Propldent]
>      name =
>      num = 1
>    propVal = [object TypedVal]
>      ival = ssval does not have a value
>      sval = \d[st|nd|rd|th]
>      val = obj does not have a value
>      valType = 3
> oPropVal2 = [object PropVal]
>    propldent = [object Propldent]
>      name =
>      num =15
>    propVal = [object TypedVal]
>      ival = ssval does not have a value
>      sval =
>      val = obj does not have a value
>      valType = 1
> oPropVal3 = [object PropVal]
>    propldent = [object Propldent]
>      name =
>      num = 17
>    propVal = [object TypedVal]
>      ival = ssval does not have a value
>      sval =
>      val = obj does not have a value
>      valType = 1
> 	qFlags = 17
> sSearch = \d[st|nd|rd|th]
>
> Any ideas from this audience?
> 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
>
>
> _______________________________________________
>
> This message is from the Framers mailing list
>
> Send messages to framers at lists.frameusers.com
> Visit the list's homepage at  http://www.frameusers.com
> Archives located at http://www.mail-archive.com/framers%40lists.frameusers.com/
> Subscribe and unsubscribe at http://lists.frameusers.com/listinfo.cgi/framers-frameusers.com
> Send administrative questions to listadmin at frameusers.com


More information about the Framers mailing list