Count the number of lines in stack

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
kevin007
Posts: 40
Joined: Mon Sep 21, 2015 7:46 am

Count the number of lines in stack

Post by kevin007 » Wed Apr 20, 2016 11:59 am

Hi All,

I have lots of lines in my stack I want count the number of lines in stack, is it possible ?

Thanks
Kevin
--
Thanks
Kevin

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

Re: Count the number of lines in stack

Post by Klaus » Wed Apr 20, 2016 12:20 pm

Hi Kevin,

what kind of "lines"?
Lines of code?
Line graphics?
Lines of coke?
:D


Best

Klaus

kevin007
Posts: 40
Joined: Mon Sep 21, 2015 7:46 am

Re: Count the number of lines in stack

Post by kevin007 » Wed Apr 20, 2016 12:24 pm

Hi, :)

I means that Line graphics

Thanks
kevin
--
Thanks
Kevin

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

Re: Count the number of lines in stack

Post by Klaus » Wed Apr 20, 2016 1:04 pm

Hi Kevin,

aha! :D

OK, for this you will need some repeat loops:
1. through all cards in your stack
2. through all graphics on ecah card and there you need to
3. check if the style of a graphic = "line"

Something like this:

Code: Select all

on mouseUp
   ## We collect the number of LINE graphics in this variable:
   put empty into TotalNumOfLines
   repeat with i = 1 to the num of cds
      put the num of grcs of cd i into tNumOfGrcs
      repeat with g = 1 to tNumOfGrcs
         if the style of grc g of cd i = "line" then
            add 1 to TotalNumOfLines
         end if
      end repeat
   end repeat
   answer "You have" && TotalNumOfLines && "line graphics in your stack."
end mouseUp
Tested and works!

Did you already check these stacks? Great learning resources for the basics of LC:
http://www.hyperactivesw.com/revscriptc ... ences.html


Best

Klaus

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

Re: Count the number of lines in stack

Post by dunbarx » Wed Apr 20, 2016 3:47 pm

Hmmm.

What Klaus may have said.

But did you mean than you have polyLines, and want to count the number of segments in those graphics?

Craig Newman

Post Reply