Copy link to clipboard
Copied
Dear all,
When a selection contains the ¶ mark, then the TR.end.offset is 0. If i manually reduce the selction to not contain the ¶ mark, then I get a reasonable value (e.g. 279).
How can I programmatically reduce the selection? I have tried the following, but this does not work
#target framemaker
main ();
function main () {
var TR = app.ActiveDoc.TextSelection;
if (TR.end.offset == 0) {
$.bp(true); // this provides a huge end.offset, not a reasonable value
TR.end.obj = TR.beg.obj;
TR.end.offset = Constants.FV_OBJ_END_OFFSET;
}
}
Hi Klaus, See if this is what you need:
#target framemaker
main ();
function main () {
var TR = app.ActiveDoc.TextSelection;
if (TR.end.offset == 0) {
TR.end.obj = TR.beg.obj;
TR.end.offset = Constants.FV_OBJ_END_OFFSET - 1;
app.ActiveDoc.TextSelection = TR;
}
}
Copy link to clipboard
Copied
Hi Klaus, See if this is what you need:
#target framemaker
main ();
function main () {
var TR = app.ActiveDoc.TextSelection;
if (TR.end.offset == 0) {
TR.end.obj = TR.beg.obj;
TR.end.offset = Constants.FV_OBJ_END_OFFSET - 1;
app.ActiveDoc.TextSelection = TR;
}
}
Copy link to clipboard
Copied
Rick, thousand thanks!
Its interaesting: if I right from the beginning select without the ¶ mark, then TR.end.offset is (in this test) 398. With the method You provide the value is 1342177279 - probably from the beginning of the document. Nevertheless the new selection is correct and the rest of the script works as expected.
Copy link to clipboard
Copied
Hi Klaus,
The Constants.FV_OBJ_END_OFFSET is an extremely high number that is always the same value, regardless of where you are in the document. When using this for a text range, it always denotes the end of the range; in the case of a paragraph, it includes the end-of-paragraph symbol. It is provided as a shorthand in order to be able to make a text range of an entire text object without knowing its actual end offset. As you can see, you can use math to change the offset as needed. In your case, we subtracted 1 from the value in order to leave the end of the paragraph out of the text range.
I think there is at least one example of this in the FDK documentation.
-Rick