AddText does not add
You know, my favorite errors ar typos... but I have not found any in my codet. So I hope You see my error.
- I have settings stored in paragraphs of a reference page and want to replace them from contents of an array.
- At line 6 fo the code snipped the alert displays that replaceString contains 5 lines.
- Leaving debug mode after line 7 displays that the current content is selected

- However, after performing line 9 nothing is inserted - the paragraph is empty
// var tr is defined in a subroutine
var replaceString = "";
for (j = 0; j < gasUserVariables.length; j++) {
replaceString = replaceString + "\n" + gasUserVariables; // \n gives new paragraphs
}
alert (replaceString);
targetDoc.TextSelection = tr; // some ¶s excluding last ¶-mark
targetDoc.Clear(0); // delete selected content
targetDoc.AddText(tr.beg, replaceString); // insert the text from the array
Where is my mistake?
BTW: in the function where I set up the selection I need to reduce FV_OBJ_END_OFFSET by 2 to exclude the final ¶ mark from the selection (snippet only):
var tr = new TextRange();
tr.beg.obj = oPara; // text range starts at the first found para
tr.beg.offset = 0;
while (oPara.ObjectValid ()) {
pgfFmt = oPara.Name;
if (pgfFmt == type) { // must not be interspearsed with other pgf formats
tr.end = new TextLoc (oPara, Constants.FV_OBJ_END_OFFSET - 2);
oPara = oPara.NextPgfInFlow;
continue;
}
break;
}
return tr;
I'm working in FM-13.

