• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to tell if LineEnd flags have been set?

Community Beginner ,
Sep 18, 2015 Sep 18, 2015

Copy link to clipboard

Copied

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.dataType)

        {

            case Constants.FTI_String:

                text += textItems.sdata;

                break;

        }

    }

    return text;

}

Now I would like to add an extra space to the string if the current textItems.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.dataType)

        {

            case Constants.FTI_String:

                text += textItems.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.

TOPICS
Scripting

Views

498

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Sep 18, 2015 Sep 18, 2015

Copy link to clipboard

Copied

LATEST

Figured it out. The flag is simply stored in the TextItem's idata.

if (textItems.idata == Constants.FTI_HardLineEnd)

{

     // code

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines