Go to the particular line

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
shalu
Posts: 72
Joined: Fri Mar 20, 2015 1:05 pm

Go to the particular line

Post by shalu » Mon Jun 22, 2015 1:19 pm

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
--
Thanks
Shalu S

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: Go to the particular line

Post by jmburnod » Mon Jun 22, 2015 1:48 pm

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
https://alternatic.ch

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to the particular line

Post by dunbarx » 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

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Go to the particular line

Post by jacque » Mon Jun 22, 2015 4:31 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Go to the particular line

Post by glenn9 » Sun Feb 14, 2021 7:13 pm

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

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Go to the particular line

Post by glenn9 » Sun Feb 14, 2021 7:15 pm

...to add to my misery I can't also figure out how to show the specified line!

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7391
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Go to the particular line

Post by jacque » Mon Feb 15, 2021 6:40 pm

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.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10319
Joined: Wed May 06, 2009 2:28 pm

Re: Go to the particular line

Post by dunbarx » Tue Feb 16, 2021 12:49 am

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

glenn9
Posts: 234
Joined: Wed Jan 15, 2020 10:45 pm

Re: Go to the particular line

Post by glenn9 » Tue Feb 16, 2021 9:03 am

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

Post Reply