Applied character format does not stop before ¶ mark
In trying to resolve the problems in What's wrong with this find-raplace script? I have discovered (FM-15, but also FM-16), that it is not possible to assign a character format to a string ending before the ¶ mark. This mark always also gets the character format:
- Have a word at the end of the paragraph: window¶
- Select the word and apply the character format. What you want to see is window¶
- But the paragraph mark also gets the character format: window¶
Hence searching for the character format brings up a very strange text range:

When inspecting this text range, I see
oTR = [object TextRange]
beg = [object TextLoc]
obj = [object Pgf] → ID 520257540
offset = 7
end = [object TextLoc]
obj = [object Pgf] → ID 520257542
offset = 0
I have not found a method to find the real end of the thingy i want (it's not the current selection, it is the string with the searched character format). The following does not work:
#target framemaker
main ();
function main () {
var oDoc = app.ActiveDoc, oPgf, oTLe, oTR, oTR2;
oTR = oDoc.TextSelection;
oPgf = oTR.beg.obj;
oTR2 = new TextRange();
oTR2.beg.obj = oTR.end.obj = oPgf;
oTR2.beg.offset = oTR.beg.offset;
oTR2.end.offset = Constants.FV_OBJ_END_OFFSET- 1;
app.ActiveDoc.TextSelection = oTR2;
}

