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.
Copy link to clipboard
Copied
Figured it out. The flag is simply stored in the TextItem's idata.
if (textItems.idata == Constants.FTI_HardLineEnd)
{
// code
}