number of lines inaccurate, sometimes?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
number of lines inaccurate, sometimes?
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?
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?
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9801
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: number of lines inaccurate, sometimes?
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: number of lines inaccurate, sometimes?
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.
I can have a whole bunch of blank lines, and the last one is not counted.
Marcus
Re: number of lines inaccurate, sometimes?
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
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
Marcus
-
- VIP Livecode Opensource Backer
- Posts: 9801
- Joined: Sat Apr 08, 2006 7:05 am
- Location: Los Angeles
- Contact:
Re: number of lines inaccurate, sometimes?
That sounds consistent with the design, since a line can contain an empty value.I can have a whole bunch of blank lines, and the last one is not counted.
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.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn