Recent

Author Topic: [SOLVED] Caret.Y-1 why so?  (Read 4121 times)

Sniper

  • New Member
  • *
  • Posts: 39
[SOLVED] Caret.Y-1 why so?
« on: April 16, 2018, 09:43:39 pm »
I get line number where caret is at the moment. I need to do this

SynEdit1.Lines[SynEdit1.CaretY-1]
but not this
SynEdit1.Lines[SynEdit1.CaretY]

Why line numbers starts from 0?
« Last Edit: April 17, 2018, 12:19:05 pm by Sniper »

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Caret.Y-1 why so?
« Reply #1 on: April 16, 2018, 09:48:29 pm »
Why line numbers starts from 0?
No idea. I also always wondered why computers do not start counting from -3,578 as that is much easier imho....

... perhaps you are able to find a hint here ?
« Last Edit: April 16, 2018, 09:58:51 pm by molly »

Sniper

  • New Member
  • *
  • Posts: 39
Re: Caret.Y-1 why so?
« Reply #2 on: April 17, 2018, 07:10:11 am »
No idea. I also always wondered why computers do not start counting from -3,578 as that is much easier imho....

... perhaps you are able to find a hint here ?

I see. So no bug here?

molly

  • Hero Member
  • *****
  • Posts: 2330
Re: Caret.Y-1 why so?
« Reply #3 on: April 17, 2018, 10:51:19 am »
I see. So no bug here?
Ah, my bad.... i interpreted your post completely wrong. sorry for that.

I thought you was questioning the (non-)sense between 0 vs 1 based indexing.

No, it is no a bug. The lines are stored inside an array and that array (list) is indexed starting from the number zero. However, we mortal humans have an issue with the number zero as normal kindergarten teaches us to start counting from 1, as does the caret position. So there is a discrepancy of 1. That is why there is need for the correction.

 

TinyPortal © 2005-2018