Newbie: Group struggle

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
kpeters
Posts: 112
Joined: Wed Mar 21, 2007 9:32 pm

Newbie: Group struggle

Post by kpeters » Sun May 06, 2007 6:54 am

I have a group containing 10 vertically oriented check boxes and I also have a list with <n> strings.

Every string in the list is to be the caption of the corresponding checkbox by position, i.e. the string in position 4 provides the caption for the fourth checkbox from the top. The checkboxes are named CB1 through CB10.

If there are less than 10 entries in the list, I'd like to hide the "extra" checkboxes, i.e. if the list contained only 9 entries then the bottom most checkbox would be hidden.

I have a feeling that this should just take a handful of lines, yet I can only come up with ugly convoluted code...

Would somebody give me hand?

TIA,
Kai

Mark
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 5150
Joined: Thu Feb 23, 2006 9:24 pm
Contact:

Post by Mark » Sun May 06, 2007 9:45 am

Kai,

What you want should be something like the following (untested):

Code: Select all

set the lockloc of grp 1 to true
repeat with x = 1 to 10 -- nr of checkboxes
  hide btn x of grp 1
end repeat
repeat with x = 1 to number of lines of theStrings
  set the tooltip of btn x to line x of theStrings -- or do you mean label?
  set the top of btn x to (the top of grp 1) + (x-1)*24
  show btn x of grp 1
end repeat
Best,

Mark
The biggest LiveCode group on Facebook: https://www.facebook.com/groups/livecode.developers
The book "Programming LiveCode for the Real Beginner"! Get it here! http://tinyurl.com/book-livecode

kpeters
Posts: 112
Joined: Wed Mar 21, 2007 9:32 pm

Post by kpeters » Sun May 06, 2007 4:04 pm

Thanks Mark ~

that's 2/3 less code than I had - I really appreciate that.

Kai

Post Reply