How to remember the position of a TextLoc at the end of a paragraph
Hi,
I have a TextLoc problem. Sorry, when this is to basic for some of you.
I have a paragraph with text.
My script does this:
1 Applies a condition to this text.
2 Adds new text after this text.
3 Then applies another condition to the new text.
I do not know, how I can remember the offset of the TextLoc at the end of the text after step 1.
I use Constants.FV_OBJ_END_OFFSET-1 for this TextLoc.
However, when I add the text, the offset is still at the end of the paragraph and not at the end of the first text.
When I store the offset in another variable, it's always at the end of this paragraph.
Is there another way to to count the offset?
Or do I have to use TextItems with GetText and somehow calculate the single text items?
This snippet illustrates what I mean. "789" should be inserted after "123". However, it is added at the end of the paragraph.
#target framemaker
"use strict";
#strict on
var loDoc, loPgf, loTLoc, loTLocStartOffset;
loDoc = app.ActiveDoc;
if (!loDoc.ObjectValid ()) {
Alert ("Document required ", Constants.FF_ALERT_CONTINUE_NOTE);
}
loFlow = loDoc.MainFlowInDoc;
loPgf = loFlow.FirstTextFrameInFlow.FirstPgf;
loTLoc = new TextLoc ();
loTLoc.obj = loPgf;
loTLoc.offset = 0;
loDoc.AddText (loTLoc, "123");
loTLoc.offset = Constants.FV_OBJ_END_OFFSET-1;
loTLocStartOffset = loTLoc.offset;
$.writeln ("loTLocStart.offset: " + loTLocStart.offset);
loDoc.AddText (loTLoc, "456");
loTLoc.offset = loTLocStartOffset;
loDoc.AddText (loTLocStart, "789");
Thank you very much for your help!
Best regards, Winfried

