Jump to content

This site uses cookies. By continuing to browse the site you are agreeing to our use of cookies. Find out more here. X
X


Photo

Multiple conditions of IF?


  • Please log in to reply
6 replies to this topic

#1 ned98

ned98

    Seeker

  • Active Members
  • 5 posts

Posted 20 April 2010 - 05:03 PM

How can I set multiple conditions for IF?
Here's my problem: I need that only if a checkbox and a radio button are selected, a button can close the program.
Here's my incorrect code:

While 1 $nMsg = GUIGetMsg() Switch $nMsg     Case $GUI_EVENT_CLOSE         MsgBox (0, "TEST", "Message Text.")         Case $STUPIDBUTTON         If $Radio1 = 1 Then         MsgBox(0, "ERRORE", "abc...")         ElseIf $Checkbox1 = 1 Then MsgBox (0, "TEST", "TEST COMPLETED.") Then Exit                 EndIf         EndSwitch WEnd

Edited by ned98, 20 April 2010 - 05:04 PM.








#2 AdmiralAlkex

AdmiralAlkex

    Here be dragons

  • Active Members
  • PipPipPipPipPipPip
  • 4,607 posts

Posted 20 April 2010 - 05:10 PM

As the helpfile say:

The expression can contain the boolean operators of AND, OR, and NOT as well as the logical operators <, <=, >, >=, =, ==, and <> grouped with parentheses as needed.


If $something1 = 1 and $something2 = 2 then
exit
endif

Or something like that :idea:


Edit: Oh and Welcome to the forum!

Edited by AdmiralAlkex, 20 April 2010 - 05:10 PM.


#3 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 20 April 2010 - 05:17 PM

While 1 $nMsg = GUIGetMsg() Switch $nMsg     Case $GUI_EVENT_CLOSE         MsgBox (0, "TEST", "Message Text.")         Case $STUPIDBUTTON         If GUICtrlRead($Radio1) = 1 Then         MsgBox(0, "ERRORE", "abc...")         If GUICtrlRead($Checkbox1) = 1 Then MsgBox (0, "TEST", "TEST COMPLETED.") Then Exit         Else             ContinueLoop         EndIf         EndSwitch WEnd

  • oapjr likes this
GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#4 ned98

ned98

    Seeker

  • Active Members
  • 5 posts

Posted 20 April 2010 - 05:52 PM

While 1 $nMsg = GUIGetMsg() Switch $nMsg     Case $GUI_EVENT_CLOSE         MsgBox (0, "TEST", "Message Text.")         Case $STUPIDBUTTON         If GUICtrlRead($Radio1) = 1 Then         MsgBox(0, "ERRORE", "abc...")         If GUICtrlRead($Checkbox1) = 1 Then MsgBox (0, "TEST", "TEST COMPLETED.") Then Exit         Else             ContinueLoop         EndIf         EndSwitch WEnd

thank you very much for your prompt reply!
But there's another little problem: when I select the radio button and the checkbox, then press the STUPIDBUTTON, Two windows pop-up: the first - MsgBox(0, "ERRORE", "abc...")- and the second - MsgBox (0, "TEST", "TEST COMPLETED." -. How can I solve this?

#5 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 20 April 2010 - 11:54 PM

Is this what you want?
While 1 $nMsg = GUIGetMsg() Switch $nMsg     Case $GUI_EVENT_CLOSE         MsgBox (0, "TEST", "Message Text.")         Case $STUPIDBUTTON         If GUICtrlRead($Radio1) = 1 AND GUICtrlRead($Checkbox1) = 1 Then             MsgBox (0, "TEST", "TEST COMPLETED.") Then Exit         Else             MsgBox(0, "ERRORE", "abc...")         EndIf EndSwitch WEnd


EDIT: Forgot the code tags

Edited by GEOSoft, 20 April 2010 - 11:55 PM.

GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"

#6 ned98

ned98

    Seeker

  • Active Members
  • 5 posts

Posted 30 April 2010 - 04:37 PM

Is this what you want?

While 1 $nMsg = GUIGetMsg() Switch $nMsg     Case $GUI_EVENT_CLOSE         MsgBox (0, "TEST", "Message Text.")         Case $STUPIDBUTTON         If GUICtrlRead($Radio1) = 1 AND GUICtrlRead($Checkbox1) = 1 Then             MsgBox (0, "TEST", "TEST COMPLETED.") Then Exit         Else             MsgBox(0, "ERRORE", "abc...")         EndIf EndSwitch WEnd


EDIT: Forgot the code tags

Thank you very much for the help! This code works perfectly.

#7 GEOSoft

GEOSoft

    Sure I'm senile. What's your excuse?

  • MVPs
  • 10,573 posts

Posted 30 April 2010 - 04:52 PM

You're wlecome and you should read up on If/ElseIf/Else/EndIf statements in the help file. If there are more than 2 conditions then you use ElseIf (usually coupled with an Else)

If $Condition_1 Then     ;; Perform some functions ElseIf $Condition_2 Then     ;; Perform a second set of functions ElseIf $Condition_3     ;; Perform a third set of functions Else     ;; Perform yet another set of functions EndIf

GeorgeQuestion about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number.Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else."Old age and treachery will always overcome youth and skill!"




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users