How to scrollToPosition()

Hey Coroners!

I got a scrollView which is cleared and then dynamically filled in by lines depending on which button is pushed.

Here is a possible situation.

The scrollView can show a range of 10 lines only. I click a button, the scrollview is filled in with 30 lines, then I scroll down to the very last line.

Then I click another button and the scrollViws is cleared and filled with only 5 lines, which are not visible, because my scrollView is still at position of the 30th line.

I would like to get the current position of the scrollView and compare it to the position of the last line to scroll it back automatically to line#5 so that the scrollView would have someting visible in it.

I know that it is possible with scrollToPosition(), but I cannot realise how to get the current position of the last line in the scrollView.

This shows some numbers, but they look random to me, looks like it is the position of the top line…

local x, y = SV:getContentPosition()

Thanks,