prismite

Button / Radio loop

3 posts in this topic

#1 ·  Posted (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 by prismite

Share this post


Link to post
Share on other sites



#2 ·  Posted (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 by Xandy

I am not a lawyer.  (-_-) Xandy About  (^o^) Discord - Xandy Programmer

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by prismite
1 person likes this

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.


Sign In Now