NvdM Posted February 25, 2007 Share Posted February 25, 2007 Hi, I have been looking at the posts in the forums, but unfortunately I can not find a solution (nor even a hint) to my problem. I hope you can help me out. Here's the situation: There are 2 variables. The conditional statement I am trying to create, should check the following: Both variables forfill the condition set. Both variables do not forfill the condition. Only one variable forfills the condition. The code (not working): ;###BoC### dim $a = "2" dim $b = "2" if $a And $b = "2" Or "3" Then MsgBox(0,"Both","Both are valid") ElseIf $a And $b <> "2" Or "3" Then MsgBox(0,"Both not","Both are not valid") ElseIf $a Or $b <> "2" Or "3" Then MsgBox(0,"One of them","One of these is not valid") Else ;;; EndIf ;###EoC### For my example this wouldn't be too much to ask for, but in my actual code the statements are a bit more complex. Therefore I'd like to keep the code as short as possible. Unlike this post ;-) Thanks in advance for looking at this!!! Cheers, NvdM Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 25, 2007 Moderators Share Posted February 25, 2007 (edited) If $b = "2" Or $b = "3" Then Edited February 25, 2007 by SmOke_N Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NvdM Posted February 25, 2007 Author Share Posted February 25, 2007 If $b = "2" Or $b = "3" Then Hi SmOke_N, Thanks for replying. Do you mean that in the first line I should write something like: if $a ="2" or $a="3" or $b = "2" Or $b="3" Then oÝ÷ Øì¢Ø^¦ºé¬,ºè®Ø^²Özg§·^ê'*'zíëp¢+/jX:·hʦy©í«H².×+y«^Â+a¶¯jXjبôߦ¢YhÁç[É«.nËZµé×è¯Múm*&zØb b殶s`¦bb33c¶ÒgV÷C³"gV÷C²÷"b33c¶ÒgV÷C³2gV÷C²FVà¢bb33c¶"ÒgV÷C³"gV÷C²÷"b33c¶"ÒgV÷C³2gV÷C²FVà¦WF2ââà Cheers, Nico. Link to comment Share on other sites More sharing options...
Developers Jos Posted February 25, 2007 Developers Share Posted February 25, 2007 Try: if ($a ="2" or $a="3") And ($b = "2" Or $b="3") Then SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
NvdM Posted February 25, 2007 Author Share Posted February 25, 2007 (edited) Try: if ($a ="2" or $a="3") And ($b = "2" Or $b="3") Then Hi Jos, Thanks to you too. Unfortunately your proposal doesn't do the trick for me. See the code as changed based upon your hint. dim $a = "24" dim $b = "3" if ($a = "2" Or $a = "3") And ($b = "2" or $b = "3") Then MsgBox(0,"Both","Both are valid") elseif ($a <> "2" Or $a <> "3") And ($b <> "2" or $b <> "3") Then MsgBox(0,"Both not","Both are not valid") elseif ($a <> "2" Or $a <> "3") And ($b = "2" or $b = "3") Then MsgBox(0,"One of them","One of these is not valid: a") Elseif ($a = "2" Or $a = "3") And ($b <> "2" or $b <> "3") Then MsgBox(0,"One of them","One of these is not valid: b") EndIf Maybe I wasn't clear about this, but the values of the variables are not constant. But only the values 2 and 3 are accepted. Cheers, Nico Edited February 25, 2007 by NvdM Link to comment Share on other sites More sharing options...
Developers Jos Posted February 25, 2007 Developers Share Posted February 25, 2007 Hi Jos, Thanks to you too. Unfortunately your proposal doesn't do the trick for me. See the code as changed based upon your hint.Hi Nico, has everything to do with the logic you use ... NQ tests should be done with And ... like this: dim $a = "2" dim $b = "3" if ($a = "2" Or $a = "3") And ($b = "2" or $b = "3") Then MsgBox(0,"Both","Both are valid") elseif ($a <> "2" And $a <> "3") And ($b <> "2" And $b <> "3") Then MsgBox(0,"Both not","Both are not valid") elseif ($a <> "2" And $a <> "3") And ($b = "2" or $b = "3") Then MsgBox(0,"One of them","One of these is not valid: a") Elseif ($a = "2" Or $a = "3") And ($b <> "2" And $b <> "3") Then MsgBox(0,"One of them","One of these is not valid: b") EndIf SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Shevilie Posted February 25, 2007 Share Posted February 25, 2007 This should work dim $a = "2" dim $b = "30" if ($a = "2" Or $a = "3") And ($b = "2" or $b = "3") Then MsgBox(0,"Both","Both are valid") elseif $a <> "2" And $a <> "3" And $b <> "2" And $b <> "3" Then MsgBox(0,"Both not","Both are not valid") elseif $b = "2" Or $b = "3" Then MsgBox(0,"One of them","One of these is not valid: a") Elseif $a = "2" Or $a = "3" Then MsgBox(0,"One of them","One of these is not valid: b") EndIf Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Shevilie Posted February 25, 2007 Share Posted February 25, 2007 Or you could do this for the easier view dim $a = "24" dim $b = "3" $atest = ($a = "2" Or $a = "3") $btest = ($b = "2" or $b = "3") If $atest And $btest Then MsgBox(0,"Both","Both are valid") ElseIf NOT($atest OR $btest) Then MsgBox(0,"Both","Both are not valid") ElseIf NOT($atest) Then MsgBox(0,"One of them","One of these is not valid: a") ElseIf NOT($btest) Then MsgBox(0,"One of them","One of these is not valid: b") EndIf Start here if you are new Valuater's AutoIT 1-2-3Looking for an UDF - Look hereDo you need to do it twice - Autoit Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted February 25, 2007 Moderators Share Posted February 25, 2007 Or you could do this for the easier view dim $a = "24" dim $b = "3" $atest = ($a = "2" Or $a = "3") $btest = ($b = "2" or $b = "3") If $atest And $btest Then MsgBox(0,"Both","Both are valid") ElseIf NOT($atest OR $btest) Then MsgBox(0,"Both","Both are not valid") ElseIf NOT($atest) Then MsgBox(0,"One of them","One of these is not valid: a") ElseIf NOT($btest) Then MsgBox(0,"One of them","One of these is not valid: b") EndIfI like. Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer. Link to comment Share on other sites More sharing options...
NvdM Posted February 25, 2007 Author Share Posted February 25, 2007 OK Guys, Got it working! Thanks to you for the solutions. I needed to change the way of thinkin'. These multiple conditional statement cases are more difficult than expected. Again: Thanks to all of you!!! Cheers, Nico. 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