the max scroll of a fld

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

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

the max scroll of a fld

Post by jmburnod » Sat May 22, 2010 4:26 pm

Hi All,

I need the max scroll of a fld.
This script work on my mac but there is maybe a more elegant and safe way

Code: Select all

function MaxScroll pFld
   set the scroll of fld pFld to 100000
   return the scroll of fld pFld
end MaxScroll
Regards

Jean-Marc
https://alternatic.ch

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

Re: the max scroll of a fld

Post by dunbarx » Sun May 23, 2010 8:26 pm

Hi.

Do you mean you need something like:

get the number of lines of fld "myField" * the textheight of fld "myField"?

or:

get the number of lines of fld "myField" * the textSize of fld "myField"?

Craig Newman

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: the max scroll of a fld

Post by FourthWorld » Sun May 23, 2010 8:46 pm

If the field's fixedLineHeight is false you may want to use the formattedHeight of the field, which will account for any variances in the textHeight of lines within the field.

That assumes the goal is to obtain a number to be used for other purposes; if the goal is just to make sure the field is scrolled to show the bottom-most line of text you can use some unusually large number for the scroll and it'll stop at the bottom of the available text:

set the scroll of fld "MyField" to 999999
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

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

Re: the max scroll of a fld

Post by jmburnod » Sun May 23, 2010 11:24 pm

Hi Craig and Richard

Thanks for reply

Craig. I can't use the num of lines because the field is not a fld list and is wrapped

Richard. You're right
Damned ! I forgot the formattedheight function

Best

Jean-Marc
https://alternatic.ch

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

Re: the max scroll of a fld

Post by jmburnod » Mon May 24, 2010 12:31 pm

Hi,

Code: Select all

function MaxScroll pFld
   set the scroll of fld pFld to 100000
   put (the scroll of fld pFld) into theMaxS
   return theMaxS
end MaxScroll
return 3058

Code: Select all

function MaxScrollbyFH pFld
   put the num of chars of fld pFld into nb
   put the formattedHeight of char 1 to nb of fld pFld into pF
   return pf
end MaxScrollbyFH
return 3600
https://alternatic.ch

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10052
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: the max scroll of a fld

Post by FourthWorld » Mon May 24, 2010 1:17 pm

jmburnod wrote:Damned ! I forgot the formattedheight function
That's why C has only 27 keywords: it makes it easy to learn. :)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply