checkbox not updating in the Rollout correctly?

checkbox not updating in the Rollout correctly?

Anonymous
Not applicable
565 Views
4 Replies
Message 1 of 5

checkbox not updating in the Rollout correctly?

Anonymous
Not applicable
Quick Question...

If I have a checkbox in a rollout with a button that is pressed, which is designed to invert the state of the checkbox no matter whether the checkbox is ticked ON or OFF, why does the following code not work?

on SelectInvert pressed do
(
if cb_wrl.state = true then
(
cb_wrl.checked = false
)
else cb_wrl.checked = true
)

Thanks,

Mike
0 Likes
566 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable
Because with if statements you should use the compare operator == and not the assign operator =


on SelectInvert pressed do
(
if cb_wrl.state == true then -- can also be "if cb_wrl.state then etc..."
cb_wrl.checked = false
else
cb_wrl.checked = true
)


-Johan
0 Likes
Message 3 of 5

Anonymous
Not applicable
also note that .state and .checked are basically the same thing. You should use one or the other in your script to make it more readable (i suggest using "checked" as "state" is too much like "triState")
0 Likes
Message 4 of 5

Anonymous
Not applicable
I agree 🙂

-Johan
0 Likes
Message 5 of 5

Steve_Curley
Mentor
Mentor
According to the Help, the TriState property is the only one (of the 3) which says "Get/Set" so use that.
0=unchecked, 1=checked, 2=indeterminate (grey/checked).

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes