Page 1 of 1

number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 7:20 pm
by trenatos
I'm trying to count the number of lines of a scrolling field (Without wrapping)

There are two ways I know of, the number of lines of field "input", and the second is setting the itemdelimiter and counting items.

But both of these seem inaccurate.

As I hit enter/backspace, adding and removing lines, the number of lines do not always count empty lines, if I put any character on a new line, it's counted properly.

Is there a better way of doing it? Or am I just using it wrong?

Re: number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 7:28 pm
by FourthWorld
If it's not including blank lines in the middle of a list in the count then that would be a bug, But if it's just the last blank line that's by design: delimiters are endings, so a CR at the end of a line will indeed place the cursor below it to allow creation of a new line, but that trailing CR is not a line in itself.

Re: number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 7:31 pm
by trenatos
It's only when the last line is blank (Has no content)

I can have a whole bunch of blank lines, and the last one is not counted.

Re: number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 7:36 pm
by trenatos
Ok, I solved it by doing:

if the last character of field "mainInput" is lf then
put the number of lines of field "mainInput" + 1 & cr after temp
end if

All it's for is displaying the line count next to the line, this seems to work for now

Re: number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 7:45 pm
by FourthWorld
I can have a whole bunch of blank lines, and the last one is not counted.
That sounds consistent with the design, since a line can contain an empty value.

Consider:
something<CR>
somethingelse<CR>
<CR>
anotherThing<CR>

In that example there a four lines, though one of them (the third one) is empty.

Here the number of lines is also four:

something<CR>
somethingelse<CR>
<CR>
<CR>

Keep in mind that the position of the cursor doesn't denote the existence of a line in the data, it's merely a convenience for you to begin create new content at that position but is not a line per se until something is added there, even if the only thing that gets added there is a CR.

Just remember that delimiters are endings and hopefully it'll become clearer.

Re: number of lines inaccurate, sometimes?

Posted: Fri Apr 24, 2015 8:10 pm
by trenatos
Yeah it makes sense now