Using multiple checkboxes to activate something - Question

hi everyone,

what i wanna do is have several checkboxes that the user can check depending on what he wants to do.

so, i have three actions, each action can be chosen to be done or not. so my basic question is, how do i combine three of these checkboxes into one if statement?

eg.:

if (string value of button "permit_robots" of window "window") = "1" then say "It Worked"

that would be one statement, but now i want something like this:

if (string value of button "permit_robots" of window "window") = "1" & (string value of button "permit_robots2" of window "window") = "1" & (string value of button "permit_robots3" of window "window") = "1"then then say "I will do all actions!"

meaning, the final action depends on what combination has been selected. so lets say i just selected the first thing, then the action to be done would look like this:

if (string value of button "permit_robots" of window "window") = "1" & (string value of button "permit_robots2" of window "window") = "0" & (string value of button "permit_robots3" of window "window") = "0"then then say "I will only do action 1"

is something like that possible? or did i just miss some basic thing? lol

huge thanks!

Hi,

I would do it this way:

tell window "window"
	set p1 to state of button "permit_robots" -- binary value 2 ^ 0 (1)
	set p2 to state of button "permit_robots2" -- binary value 2 ^ 1 (2)
	set p3 to state of button "permit_robots3" -- binary value 2 ^ 2 (4)
end tell
set stateIndex to p3 * 4 + p2 * 2 + p1 -- calculate index

if stateIndex is 7 then
	say "I will do all actions!"
else if stateIndex is 1 then
	say "I will only do action 1"
end if

dude looks great!

ill give it a shot and let you know :smiley:

Interesting. :slight_smile:

Alternatively:

tell window "window"
	set p1 to state of button "permit_robots"
	set p2 to state of button "permit_robots2"
	set p3 to state of button "permit_robots3"
end tell

if p1 and p2 and p3 then

else if p1 and p2

else if p1 and p3

else if p2 and p3

else if p1

else if p2

else if p3

end if

thanks both worked like a charm! i ended up using bruces. nothing against yours stefan :smiley:

solved :smiley: