each keyword for buttons

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
snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

each keyword for buttons

Post by snm » Thu Jun 07, 2012 1:53 pm

Is it possible to repeat the script step for each button grouped in group?
For example:

Code: Select all

repeat for each btw theButton in grp "myGroupOfButtons"
  do something
end repeat
Marek

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

Re: each keyword for buttons

Post by Klaus » Thu Jun 07, 2012 2:18 pm

Hi Marek,

no, "for each..." only works with chunk expressions like "line", "word" etc.
I wish it would also work with objects like cards and buttons etc.

You need to loop through "the num of btns of grp XYZ" in this case.


Best

Klaus

sturgis
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 1685
Joined: Sat Feb 28, 2009 11:49 pm

Re: each keyword for buttons

Post by sturgis » Thu Jun 07, 2012 2:19 pm

Nope, don't believe you can use for each with buttons or any type of controls unless you keep a list of the buttons yourself at which point you can

repeat for each line tLine in myGroupedButtonList

In this case the easiest way is with an i = 1 to the number of buttons in group "groupname"

Code: Select all

repeat with i = 1 to the number of buttons in group "mygroup"
    put the name of button i of group "mygroup" after field 1
end repeat

snm
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 253
Joined: Fri Dec 09, 2011 11:17 am

Re: each keyword for buttons

Post by snm » Thu Jun 07, 2012 2:27 pm

Thanks a lot Klaus and Strugis.

Marek

Post Reply