Jump to content

Recommended Posts

Posted

Hello everone,

I'm creating a GUI, with radios. Radio's working, everything is fine. Here's a part of my script:

$nMsg = GUIGetMsg()
        Switch $nMsg
            Case $GUI_EVENT_CLOSE
                Exit
            Case $Button_Transfer
                If GUICtrlRead($Input)= Not "" And $Einde = False Then Transfer()
            Case $Radio1
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio6,1)
            Case $Radio2
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)
            Case $Radio3
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)
            Case $Radio4
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)
            Case $Radio5
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio2,1)
            Case $Radio6
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio1,1)
            Case $Radio7
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)
            Case $Radio8
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)
;           Case $Button_Undo
;               Something
            Case $Button_Return
                MsgBox(4, "Waarschuwing", "Als je teruggaat, verlies je alle voortgang." & @CRLF & "Wil je doorgaan?")
                Start()
        EndSwitch

My problem: If I load the complete script with only 2 players, Radio 3,4,5 and 6 aren't loaded, and thus the script gives an error while loading the script above. I can and have used IsDeclared(), but how can I insert the IsDeclared part into this swith? Something like

Case $Radio2 if IsDeclared("PLayer3")=1
                If $SpelersOver=2 And $Einde=0 Then GUICtrlSetState($Radio5,1)

Thanks in advance,
Silas

Posted

You must switch to Select ;)

My UDFs and Tutorials:

  Reveal hidden contents

 

Posted

The condition to check can only be defined once for Switch and hence is the same for all Case statements, whereas the condition can be different for each Case statement for Select.

My UDFs and Tutorials:

  Reveal hidden contents

 

  • Moderators
Posted

To add on to that, if you crack open the help file and compare the example for Switch to the one for Select, the differences should be immediate and plain to see.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...