How can I access objects of a group ?

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
atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

How can I access objects of a group ?

Post by atout66 » Thu May 22, 2014 8:54 am

Hi to all,
Everything is in the title, but to say more, what should I write if I want to do this:

Code: Select all

put the number of objects of group "myGrp" into lesObj
repeat with xxx = 1 to lesObj
get the hilite of object xxx of group "myGrp"
it IT is TRUE then
blablabla
end if
end repeat
The <blablabla> is a secret instruction I can not provided in this forum :lol:

Thanks in advance for your help, Jean-Paul.
Discovering LiveCode Community 6.5.2.

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

Re: How can I access objects of a group ?

Post by Klaus » Thu May 22, 2014 11:44 am

Bonjour Jean-Paul,

"hilite"? So you are trying to check all buttons (radio- or checkbox) in a group?
Then do this:

Code: Select all

...
repeat with i = 1 to the num of btns of grp "myGrp"
  if the hilite of btn i of grp "myGrp" then
     do_my_secret_stuff
  end if
end repeat
...
Hint:
you see my line: if the hilite of btn i of grp "myGrp" then...
And may wonder why i do not write ...= TRUE!?

If you do NOT provide the value you are looking for, then the engine presumes you mean in fact:
if the hilite of btn i of grp "myGrp" = TRUE then

Looks like the engine is an optimist, which saves us some typing :D


Best

Klaus

dave.kilroy
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 858
Joined: Wed Jun 24, 2009 1:17 pm
Contact:

Re: How can I access objects of a group ?

Post by dave.kilroy » Thu May 22, 2014 2:21 pm

Klaus - I hadn't thought of that but you are right - to the engine "the glass is always half-full" :)
"...this is not the code you are looking for..."

atout66
Posts: 266
Joined: Wed Feb 02, 2011 12:31 pm

Re: How can I access objects of a group ?

Post by atout66 » Thu May 22, 2014 2:52 pm

OK, thanks for the syntax Klaus:
repeat with i = 1 to the num of btns of grp "myGrp"

Kind regards, Jean-Paul.
Discovering LiveCode Community 6.5.2.

Post Reply