the_lord_mephy Posted October 29, 2004 Share Posted October 29, 2004 I have this code: If Not @DesktopHeight = "600" and not @DesktopWidth = "800" Then MsgBox(0, "Error", "Please set your desktop height to 600 and your desktop width to 800. Then restart the program") Exit EndIf I tried setting my desktop width and height to 768x1024 but the msgbox doesn't execute and the program continues to run. Please help me. My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted October 29, 2004 Share Posted October 29, 2004 (edited) Maybe this will help: If Not( (@DesktopHeight = "600") and (@DesktopWidth = "800") ) Then MsgBox(0, "Error", "Please set your desktop height to 600 and your desktop width to 800. Then restart the program") Exit EndIf *** Matt @ MPCS EDIT: Larry is quick today Edited October 29, 2004 by Matt @ MPCS Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 29, 2004 Author Share Posted October 29, 2004 thanks guys My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
scriptkitty Posted October 29, 2004 Share Posted October 29, 2004 (edited) try this: tooltip(@DesktopHeight&"x"&@DesktopWidth,0,0) If @DesktopHeight<>600 and @DesktopWidth<>800 Then MsgBox(1, "Error", "Please set your desktop height to 600 and your desktop width to 800. Then restart the program") Exit EndIf sleep(1000) I like the tooltip and sleep to show what yours is for debug. Edited October 29, 2004 by scriptkitty AutoIt3, the MACGYVER Pocket Knife for computers. Link to comment Share on other sites More sharing options...
the_lord_mephy Posted October 29, 2004 Author Share Posted October 29, 2004 Ooh I like that, Thanks script kiddy. Good idea My site for HTML Help :)[quote name='Valik' date='Oct 15 2004, 12:29 PM']Maybe nobody is an "elite uber-coder" like me because thinking is a capital offense in today's online-world?[right][snapback]36427[/snapback][/right][/quote] Link to comment Share on other sites More sharing options...
trids Posted November 1, 2004 Share Posted November 1, 2004 Beware of AND-ing negative expressions .. ie <>, or "not equal"Matt's suggestion will give the desired results ..If Not( (@DesktopHeight = "600") and (@DesktopWidth = "800") ) Then.. But to simplify it by using negative expressions, you need to change AND to OR . So this is not equivalent:If @DesktopHeight<>600 and @DesktopWidth<>800 ThenBut this will give you the same results:If @DesktopHeight<>600 or @DesktopWidth<>800 ThenHope this helps Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 1, 2004 Share Posted November 1, 2004 (edited) @trids, You have a good point but I don't know if your example is valid. When reading the first example:If @DesktopHeight<>600 and @DesktopWidth<>800 ThenLogically it reads:If the desktop height is less than or greater than 600 AND the desktop width is less than or greater than 800 then <execute following code>That says that both the height and width cannot be equal to 600 or 800 respectivly. While your second example reads:If @DesktopHeight<>600 or @DesktopWidth<>800 ThenLogically it reads:If the desktop height is less than or greater than 600 OR the desktop width is less than or greater than 800 then <execute following code>Which means that if either the width=800 or the height=600 the code will be executed. Technically I believe you are incorrect in your statement, the correct comparison would require that both the height and width not equal their respective values, therefore the correct code would be:If @DesktopHeight<>600 and @DesktopWidth<>800 ThenOf course in this situation it makes absolutly no difference which is used because we are working with monitor resolution that would always have a width of 800 if the height is 600 (true only when using standard video cards).I apologize if I am incorrect here but this logic makes sense to me that is why I am posting this correction.*** Matt @ MPCSADDITION: This proves Larry's solution correct also. Edited November 1, 2004 by Matt @ MPCS Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 1, 2004 Share Posted November 1, 2004 Try the following example if you don't believe me: If 1<>1 And 1<>2 Then MsgBox(0,"","Exp[b][/b]ression is true") EndIf Result: No MsgBox Shown If 1<>1 Or 1<>2 Then MsgBox(0,"","Exp[b][/b]ression is true") EndIf Result: MsgBox Shown *** Matt @ MPCS Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 1, 2004 Share Posted November 1, 2004 (edited) I stand corrected... I failed to dumb down my approach: If Not( (@DesktopHeight = "600") and (@DesktopWidth = "800") ) Then You are absolutly correct. Examples: If Not((1=1) Or (1=2)) Then MsgBox(0,"","Exp[b][/b]ression is true") EndIf Result: No messagebox shown If Not((1=1) And (1=2)) Then MsgBox(0,"","Exp[b][/b]ression is true") EndIf Result: Messagebox shown Addition: This proves Larry's answer to be better than mine though: If @DesktopHeight <> 600 And @DesktopWidth <> 800 Then *** Matt @ MPCS Edited November 1, 2004 by Matt @ MPCS Link to comment Share on other sites More sharing options...
trids Posted November 1, 2004 Share Posted November 1, 2004 Of course in this situation it makes absolutly no difference which is used because we are working with monitor resolution that would always have a width of 800 if the height is 600 (true only when using standard video cards).<{POST_SNAPBACK}>.. that's true, but your orginal code is a closer match with the intruction to the user "Please set your desktop height to 600 and your desktop width to 800. Then restart the program".Bottom line is: you want the screen to be at 600 x 800 .. and if it's not, then send the message. => In other words: if there is anything wrong with the resolution, send the message. => In other words: if height is wrong OR width is wrong, send the message. => In other words: If @DesktopHeight<>600 OR @DesktopWidth<>800, send the message.I'm not basing my position on video cards, but on pure Boolean logic. And the only reason I mentioned you at all is that yours was correct .. other than that, it makes no difference to me whose solution is correct or wrong Link to comment Share on other sites More sharing options...
Matt @ MPCS Posted November 1, 2004 Share Posted November 1, 2004 I'm not basing my position on video cards, but on pure Boolean logic. And the only reason I mentioned you at all is that yours was correct .. other than that, it makes no difference to me whose solution is correct or wrongI know that, I was just trying to prove to myself that I could still think through boolean logic logically and failed miserably. Thanks for your compliment, but my code is actually incorrect... Larry's is better.*** Matt @ MPCS Link to comment Share on other sites More sharing options...
trids Posted November 1, 2004 Share Posted November 1, 2004 .. that's ok - it's easy to tie yourself in kNOTs when reading Boolean logic from an American English point of view! 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