1 Reply Latest reply on Sep 18, 2015 4:06 PM by carlm80163462

    How to tell if LineEnd flags have been set?

    carlm80163462

      Hi all,

       

      I'm quite new to FrameMaker scripting and trying to figure out how to tell if flags have been set. I have a function that takes an element and returns its text as a string. Simple enough:

       

      function getElementText(elem)

      {

          var text = "";

          var textItems;

          var textItems = elem.GetText(Constants.FTI_String);

        

          for (var i = 0; i < textItems.length; i++)

          {

              switch (textItems[i].dataType)

              {

                  case Constants.FTI_String:

                      text += textItems[i].sdata;

                      break;

              }

          }

          return text;

      }

       

       

      Now I would like to add an extra space to the string if the current textItems[i].sdata ends with a forced return. I understand that I can use FTI_HardLineEnd flag to determine this, but I'm not really sure how to go about seeing if this flag has been set.

      So far I have:

       

      function getElementText(elem)

      {

          var text = "";

          var textItems;

          var textItems = elem.GetText(Constants.FTI_String | Constants.FTI_LineEnd);

        

          for (var i = 0; i < textItems.length; i++)

          {

              switch (textItems[i].dataType)

              {

                  case Constants.FTI_String:

                      text += textItems[i].sdata;

                      break;

                  case Constants.FTI_LineEnd:

                      // see if flag has been set

                      // if it has:

                           text += " ";

                      break;

              }

          }

          return text;

      }

       

       

      I've searched through the scripting guide and any other resources I can get my hands on, but can't seem to figure out around how to tell if the flag has been set. Any help is greatly appreciated.

       

      Thanks.