Clearing all checkboxes in a stack

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
bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Clearing all checkboxes in a stack

Post by bidgeeman » Fri May 29, 2009 6:30 am

Hello,

I have a group of checkboxes called "CheckboxGroup" on several different cards. The CheckboxGroup has the same name on each card.

I am using this code to clear the checkboxes on each card but I would like to clear ALL the checkbox groups in the stack:

Code: Select all

repeat with i = 1 to the number of buttons in group "CheckboxGroup" 
unhilite button i of group "CheckboxGroup" 
Can anyone offer some help?
Many thanks
Bidge

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

Post by Mark » Fri May 29, 2009 8:17 am

Hi Bidge,

If the sharedHilite of the checkboxes is false, then probably something like this:

Code: Select all

on TurnOffCheckboxes
  repeat with x = 1 to number of cards
    repeat with y = 1 to number of buttons of grp "CheckboxGroup" of cd x
      set the hilite of btn y of grp "CheckboxGroup" of cd x to false
    end repeat
  end repeat
end TurnOffCheckboxes
Does this work for you?

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 29, 2009 9:05 am

Hi Mark.
For some reason it's not working? I get an error on compile at this point:

on TurnOffCheckboxes

Cheers
Bidge

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

Post by Mark » Fri May 29, 2009 9:12 am

What exactly did you do, Bidge?

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 29, 2009 9:22 am

Hi Mark.
I copied the cade and pasted it into my "clear" button but when I clicked compile this error came up at the start.

button "Clear Fields": compilation error at line 8 (Handler: error in command) near "on", char 1

Cheers
Bidge

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

Post by Mark » Fri May 29, 2009 9:35 am

Hi Bidge,

Are you sure that the script is completely empty except for the code I posted here? If not, what else is in the button script?

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

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 29, 2009 9:43 am

Hi Mark.

This is what is in the button script:


on TurnOffCheckboxes
repeat with x = 1 to number of cards
repeat with y = 1 to number of buttons of grp "CheckboxGroup" of cd x
set the hilite of btn y of grp "CheckboxGroup" of cd x to false
end repeat
end repeat
end TurnOffCheckboxes

EDIT: Mark. I tried it again and the compile errr went away but nothing happened.

Cheers
Bidge

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

Post by Mark » Fri May 29, 2009 9:47 am

Bidge,

Have you tries restarting Revolution already? What else have you tried? I have tested the script and it doesn't cause an error here, when I compile it. There is probably a bug in Revolution or you have a script still running without knowing it (e.g. a repeat loop or a script with a recursive send command or because there is another script with an execution error, which hasn't been stopped yet).

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

bonbon
Posts: 62
Joined: Thu Jul 17, 2008 11:48 pm

Post by bonbon » Fri May 29, 2009 9:56 am

Hi Bidge,

Sticking my nose in ... what I think is happening is this: Mark's code is actually a procedure (I think Revolution calls this a custom command). So you could place Mark's code in the card (or stack) script, and then all you need to put in the button script is

Code: Select all

TurnOffCheckboxes 
If you only use the code in one place, and you want to put all of the code in the button script, all you need to do is remove the first and last lines, i.e. get rid of

Code: Select all

on TurnOffCheckboxes 
and

Code: Select all

end TurnOffCheckboxes 
Hope this helps.

Pete

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 29, 2009 10:00 am

Hi Mark.

Here's a new test stack I made. Can you chaeck it to see what I've done wrong?

http://www.errolgray.com.au/CheckboxGroup.rev

EDIT: Oh...Sosorry....I'm an idiot. I replaced "on mouseUp" with "on TurnOffCheckboxes" it's working. Thanks Mark.


Thanks :oops:
Bidge

bidgeeman
Posts: 495
Joined: Wed Feb 21, 2007 7:58 am

Post by bidgeeman » Fri May 29, 2009 10:20 am

Hi Mark.
There was another error being thrown up but I tracked it down to the fact that I did'nt have a CheckboxGroup" on every card in the stack. Once I placed a group on every stack the error dissapeared.

Thanks again for your help.

Cheers
Bidge

Post Reply