I think the easiest way to count lines in a paragraph is to retrieve the text items, then just look at the length of the array. For example:
var ti = pgf.GetText(Constants.FTI_String);
The length of "ti" will be the number of lines in the paragraph. For example, if the paragraph is 5 lines long, then:
ti.len == 5
After posting that, I thought of this, which seems to do the same thing:
var ti = pgf.GetText(Constants.FTI_LineEnd);
If it requires less memory and/or processing, that might be better. I don't know if it does or not.
Hi Russ (and Philippe)
The array of strings may in fact have more elements than the number of lines. I cannot give you precise examples for unstructured text, but I did see them. The search for LineEnd is safer.
Hello Russ (and Rick),
I was thinking that the FTI_LineEnd was giving type of the end of line (see something like than in the FM scripting PDF ... but my english not so good, maybe why I understand wrong).
Thanks alot for the help
Yes, the LineEnd markers also include the type of the end of line (hard return at the end of a paragraph, soft return when the line is wrapped because there is no more space for the characters). This is because you can also ask for all the LineEnd markers in a section (or in an element in structured FM), not just in a single paragraph.
But when you get the LineEnd markers in a single paragraph (in unstructured FM), you will only have one hard return and possibly a bunch of soft returns. For your script, you only need to know if the total number of LineEnd markers has changed.
Thanks jang (sorry i put Rick previously, was an error from me )
Just a note about Russ's first reply: the number of FTI_String items can be much more than the number of lines. You get a new FTI_String every time there is a property change in the paragraph or if a string is interrupted by a marker, text frame, table, etc. The FTI_LineEnd count is definitely the way to go.
Rick and Jang, thanks for straightening me out!