prismite Posted April 28, 2017 Share Posted April 28, 2017 (edited) Hi all! Is it possible to vary the function of a button press using a radio? I've tried using the layout below but it simply loops redoing whatever radio is selected, not even waiting for the button push. Any input is appreciated! While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 AND GUICtrlRead($Radio1) = $GUI_CHECKED Function1a() Case $Button1 AND GUICtrlRead($Radio2) = $GUI_CHECKED Function1b() Case $Button2 Function2() Case $Button3 Function3() EndSwitch WEnd Edited April 28, 2017 by prismite Link to comment Share on other sites More sharing options...
Xandy Posted April 28, 2017 Share Posted April 28, 2017 (edited) The problem is the structure of the Switch $nMsg (I think) Have a look at: Switch Case doesn't understand: And I fixed the first button for you, apply the changes to all and it should work. While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 If GUICtrlRead($Radio1) = $GUI_CHECKED Then Function1a() Case $Button1 AND GUICtrlRead($Radio2) = $GUI_CHECKED Function1b() Case $Button2 Function2() Case $Button3 Function3() EndSwitch WEnd Untested I hope I did alright. Edited April 28, 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...
prismite Posted April 28, 2017 Author Share Posted April 28, 2017 (edited) I appreciate the quick response! Unfortunately, this did not break the loop, as it runs whichever function about 10-20 times a second. I had used Switch in this script in the iteration before I involved a radio and it worked beautifully. Clearly I broke it. Update: Actually, you had the right of it, Kudos! I forgot to comment out the non-working part of the text. Once removed, the above worked as explained! Gracias! Edited April 28, 2017 by prismite Xandy 1 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