PunkoHead Posted June 20, 2017 Share Posted June 20, 2017 (edited) Hi guys, I have another question regarding AutoIT. I have the code below but it does not work. Could you please assist? Func IsTheCheckboxChecked ($CB1, $CB2) If GUICtrlRead ($CB1) = 1 Then Return 1 ElseIf GUICtrlRead ($CB2) = 1 Then Return 2 ElseIf (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then Return 3 EndIf EndFunc $Digital = GUICtrlCreateCheckbox("Digital", 480, 80, 73, 17) $Physical = GUICtrlCreateCheckbox("Physical", 560, 80, 81, 17) If IsTheCheckboxChecked($Digital, $Physical) = 1 Then $EnabledItemTypesText = "Enabled Item Types: Digital" ElseIf IsTheCheckboxChecked($Digital, $Physical) = 2 Then $EnabledItemTypesText = "Enabled Item Types: Physical" ElseIf IsTheCheckboxChecked($Digital, $Physical) = 3 Then $EnabledItemTypesText = "Enabled Item Types: Digital and Physical" EndIf However, when both are ticket the output is only Digital. If I select only the Physical, only Physical is displayed in the output... Any ideas? Thanks in advance! Edited June 20, 2017 by PunkoHead Link to comment Share on other sites More sharing options...
Xandy Posted June 20, 2017 Share Posted June 20, 2017 What's up with that '5' before the 'Then' in the last ElseIf? Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted June 20, 2017 Share Posted June 20, 2017 (edited) Put this first: ElseIf (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then Put it before the single checks. You need to evalute the doubles before the singles b/c you stop looking after you find a single. How can it ever reach the doubles if it exits on a single? Func IsTheCheckboxChecked ($CB1, $CB2) If (GUICtrlRead ($CB1) = 1) And (GUICtrlRead ($CB2) = 1) Then Return 3 ElseIf GUICtrlRead ($CB1) = 1 Then Return 1 ElseIf GUICtrlRead ($CB2) = 1 Then Return 2 EndIf EndFunc Edited June 20, 2017 by Xandy PunkoHead 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
PunkoHead Posted June 20, 2017 Author Share Posted June 20, 2017 Wow.. This worked, but I have no idea why... Is there any explanation? Thanks, btw! Link to comment Share on other sites More sharing options...
Xandy Posted June 20, 2017 Share Posted June 20, 2017 (edited) Refresh webpage to see my edited post (ABOVE for explanation) Edited June 20, 2017 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted June 20, 2017 Share Posted June 20, 2017 (edited) Your Elses would exit the condition block, but you Return as well Edited June 20, 2017 by Xandy Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Xandy Posted June 20, 2017 Share Posted June 20, 2017 (edited) Doing either an Else, ElseIf, or Return on event would stop the condition block at that event. Future more complicated events would never be reached if a event fragment was met first. Edited June 20, 2017 by Xandy PunkoHead 1 Human Male Programmer (-_-) Xandy About (^o^) Discord - Xandy Programmer MapIt (Tile world editor, Image Tile Extractor, and Game Maker) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now