Page 1 of 1

Go to the particular line

Posted: Mon Jun 22, 2015 1:19 pm
by shalu
I am Beginner in Live code, I am looking for the code to "go to the particular line in Scrolling filed". I am use the following code but it's not working :(
go to the line 200 of field "SField"
Here SField is the name of the Scrolling field. Is it possible

Re: Go to the particular line

Posted: Mon Jun 22, 2015 1:48 pm
by jmburnod
Hi Shalu,

Code: Select all

select line 200 of field "SField"
is one way to select one line and it set the scroll to show the found line :D
Best regards
Jean-Marc

Re: Go to the particular line

Posted: Mon Jun 22, 2015 3:10 pm
by dunbarx
Hi.

You can also set the scroll of the field, which is a property of that field. This is in pixels, and depends on the textHeight. So you could:

Code: Select all

set the scroll of fld "yourField" to the textHeight of fld "yourField" * 20
This would scroll so that line 21 of the field appears at the top, and can be a very useful tool to have. Any interest in finding out why the scroll goes to the line after the one you specified?

Craig Newman

Re: Go to the particular line

Posted: Mon Jun 22, 2015 4:31 pm
by jacque
Also note that "the" is never used with objects, only with properties and some forms of functions. So we don't say "the field", just "field" is enough.

Re: Go to the particular line

Posted: Sun Feb 14, 2021 7:13 pm
by glenn9
dunbarx wrote:
Mon Jun 22, 2015 3:10 pm
Hi.

You can also set the scroll of the field, which is a property of that field. This is in pixels, and depends on the textHeight. So you could:

Code: Select all

set the scroll of fld "yourField" to the textHeight of fld "yourField" * 20
This would scroll so that line 21 of the field appears at the top, and can be a very useful tool to have. Any interest in finding out why the scroll goes to the line after the one you specified?

Craig Newman
Hi Craig,

I'm stumped!

Can you put me out of my misery why the scroll goes to the line after the one specified...?!

Thanks,

Glenn

Re: Go to the particular line

Posted: Sun Feb 14, 2021 7:15 pm
by glenn9
...to add to my misery I can't also figure out how to show the specified line!

Re: Go to the particular line

Posted: Mon Feb 15, 2021 6:40 pm
by jacque
A field that is not scrolled at all has a vScroll of 0. If the textheight of the field is, say, 18 then multiplying it by 1 would set the field scroll to 18, which pushes line 1 out of view. Basically, multiplying the textheight by the number of lines will always scroll one too many lines.

For ease of use I like the "select" method myself. The engine handles all the details for you that way.

Re: Go to the particular line

Posted: Tue Feb 16, 2021 12:49 am
by dunbarx
Can you put me out of my misery why the scroll goes to the line after the one specified...?!
Laziness on my part. I should also have said that the "fixedLineHeight" of the field must be set, and should have offered this, as per Jacque's comment:

Code: Select all

-- goes to line 40
set the scroll of fld 1 to the textheight of fld "yourField" * 40 - the textheight of fld "yourField"
The suggestion ( a good one) to select a particular line will place that line at the bottom of the visible field if the current scroll is below that line, or at the top if above. I just found this out today.

Anyone else notice this?

Craig

Re: Go to the particular line

Posted: Tue Feb 16, 2021 9:03 am
by glenn9
Thanks Craig, Jacque,

Both of your comments were very helpful, now have a much better understanding of how to get to a specific line.

Kind regards,

Glenn