Counting number of lines of TEXT

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Counting number of lines of TEXT

Post by Nakia » Tue May 29, 2012 10:47 am

Hi.

I have a text fld that I need to check that it contains a FULL 19 lines of TEXT (Each line must contain TEXT).
I have the following below but it is counting empty lines which is not suitable for my purpose.
Is there a way to calculate number of lines of Text That actually contain Text?


Code: Select all

on checkFullData
   if number of lines of formattedText  of field "ScoreRunS1" = "19"
   then
      writeData
   else
      answer warning "Data Missing, Please enter a full set of scores" titled "Validating Data"
   end if
end checkFullData

Klaus
Posts: 14212
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Counting number of lines of TEXT

Post by Klaus » Tue May 29, 2012 12:06 pm

Hi Nakia,

do this:
1. get thet text you want to check
2. delete all empty lines!
3. do your count and check

Code: Select all

...
## Always a good idea to put text into a variable, since accessing FIELDS is much more time consuming than this!
put the text of fld "xyz" into tCompleteText

## Remove empty lines! 
## Check "FIULTER" in the dictionary!
filter tCompleteText without EMPTY

## No do the count
## Hint: no quotes around numbers!
if the num of lines of tCompleteText <> 19 then
   writedata
else
   ## blame user here..
end if
...
Best

Klaus

Nakia
Posts: 425
Joined: Tue Feb 21, 2012 8:57 am

Re: Counting number of lines of TEXT

Post by Nakia » Wed May 30, 2012 8:55 am

Thanks so much.
Worked exactly as expected.

Post Reply