Find empty textline by ExtendScript
Dear friends,
While this task was solved in FrameScript with ease ...
If ActiveDoc = 0
MsgBox 'No active document. ';
LeaveSub;
EndIf
Set vGraphic = FirstGraphicInDoc;
Loop While(vGraphic)
Set vNextGraphic = vGraphic.NextGraphicInDoc;
If vGraphic.ObjectName = 'TextLine'
If vGraphic.Text = ''
Delete Object(vGraphic);
EndIf
EndIf
Set vGraphic = vNextGraphic;
EndLoopI struggle in ES by the simple fact, that there is no text attribute available:
Fot the test I use an FM document without Ref pages. On the only one body page I have removed everything but a text line containing some text.
Text line is found, but I have no clue how to chek whether it is empty or not, because I can't get to the string:
FindEmptyTextLine = function () {
// Reference E:\FM-FrameScript\DeleteEmptyTextlines.fsl
var oDoc, oGraphic, objType, asText, oTextLoc;
oDoc = app.ActiveDoc;
if (!oDoc.ObjectValid()) { return;}
oGraphic = oDoc.FirstGraphicInDoc;
while (oGraphic.ObjectValid()) {
objType = oGraphic.constructor.name;
if (objType == "TextLine") {
$.bp(true);
oTextLoc = new TextLoc (oGraphic, 0); // how to find the string?
asText = oGraphic.ObjectAttributes;
if (asText.length == 0) { // string array is empty
bFound = true;
} else { // is there a real textline ?
alert ("have we found a real text line?");
}
oGraphic.GraphicIsSelected = true; // Nothing to see
}
oGraphic = oGraphic.NextGraphicInDoc;
}
return oGraphic;
} //--- end FindEmptyTextLine
var object = FindEmptyTextLine (); Any help available here?
Thanks You.

