counting lines with no CR

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
gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

counting lines with no CR

Post by gyroscope » Thu Oct 08, 2009 6:50 pm

Hi, I'm going to kick myself here, I know:

I have a field which does not accept returns. On a button click I wish to put the amount of actual lines in the field into a variable.
The problem is if there is more than one line without returns, it still counts the lines as 1 (i.e as 1 wrapped line). I need to know the amount of visible lines in the field.

So my question please:

How to count the actual lines showing in a field

I should know this but I've forgotten, sorry... :(

Any help appreciated.

:)

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

Post by FourthWorld » Thu Oct 08, 2009 8:07 pm

The formattedText property of fields will return the contents of a field with hard returns inserted where the field has soft-wraps. So you could write:

get the number of lines of (the formattedText of fld 1)
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

gyroscope
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 404
Joined: Tue Jan 08, 2008 3:44 pm
Contact:

Post by gyroscope » Fri Oct 09, 2009 12:02 am

Excellent, thank you Richard.

:)

Post Reply