Quantcast
Channel: Adobe Community: Message List - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 3715

Re: Is Find() dependable or should I use something else?

$
0
0

My code above was not correct, it did not find changebars. I had to discover some arcane (to me at least) bitwise operator knowledge that is not included in the Fm docs. I realized that to find a changebar, the result of ANDing TextItem.idata and Constants.FTF_CHANGEBAR must be greater than 0. So my code worked when I changed this line:

     if (x == 0) {

To this:

     if (x > 0) {

Here is the working code (corrections and suggestions welcome!):

 

var doc = app.ActiveDoc;

var pgf = doc.MainFlowInDoc.FirstTextFrameInFlow.FirstPgf;

 

 

while(pgf.ObjectValid()){

    var textitems = pgf.GetText(Constants.FTI_CharPropsChange);

   

    for (var i=0; i < textitems.len ; i +=1)

    {

        // The result of the AND must be greater than 0 or no changebar.

        var x = textitems[i].idata & Constants.FTF_CHANGEBAR;

        if (x > 0) {

           $.writeln ('I have a changebar');

        }

    }

    pgf = pgf.NextPgfInFlow;

}

 

 

Now what the significance of the TextItem.idata field is, is still beyond me. The docs say it is "The ID of the object if the text item is an object." But why would you need to AND that ID with some constant?  Mark


Viewing all articles
Browse latest Browse all 3715

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>