rudi Posted July 6, 2007 Share Posted July 6, 2007 (edited) Hello everybody I think I miss something very basic testing strings? I'm using AutoIT3 Version 3.2.4.9 and SCITE 1.68 (Same results on WinXP-SP2 and Win2003-R2, SP2, German Ed.) Here is what I tested, and I do not understand the results: expandcollapse popup$dummy="\\" ;Test One: Values are *NOT* equal. if $dummy="C_" Then MsgBox(0,"1: 'true'","") Else MsgBox(0,"1: 'false'","correct result") EndIf ;Test Two: Values *ARE* equal if $dummy="\\" Then MsgBox(0,"2: 'true'","correct result") Else MsgBox(0,"2: 'false'","") EndIf ;Test Three: Values are *NOT* equal, *NOT* is used, so should give a true if not $dummy="C_" Then MsgBox(0,"3: 'true'","") Else MsgBox(0,"3: 'false'","WRONG result: $Dummy = " & $dummy & @lf & @lf & 'if not $dummy="C_"' & @lf & @lf & 'The Values are *NOT* equal. "IF NOT..." was used, so should give "TRUE"') EndIf ;Test Four: Values *ARE* equal, *NOT* is used, so should give a false if not $dummy="\\" Then MsgBox(0,"4: 'true'","This would be displayed, if 'if NOT' would generally fail") Else MsgBox(0,"4: 'false'","Here" & @lf & @lf &"'if not ...'" & @lf &@lf &"*DOES* work fine: Values *ARE* equal, 'if not ...' was used, resulting 'false' (correct)") EndIf ;################################################################################### $dummy="C_" MsgBox(0,"info","Now $dummy is set to ""C_""",3) ; 5: Values *ARE* equal ==> true if $dummy="C_" Then MsgBox(0,"5: 'true'","correct result") Else MsgBox(0,"5: 'false'","") EndIf ; 6: Values *NOT* equal ==> false if $dummy="\\" Then MsgBox(0,"6: 'true'","") Else MsgBox(0,"6: 'false'","correct result") EndIf ; 7: NOT used. Values equal. ==> false if not $dummy="C_" Then MsgBox(0,"7: 'true'","") Else MsgBox(0,"7: 'false'","Here" & @lf & @lf &"'if not ...'" & @lf &@lf &"again *DOES* work fine: Values *ARE* equal, 'if not ...' was used, resulting 'false' (correct)") EndIf ; 8: "IF NOT ... " will be used. Values are *NOT* equal ==> true if not $dummy="\\" Then MsgBox(0,"8: 'true'","This should show up (it doesn't!)") Else MsgBox(0,"8: 'false'","WRONG result: $Dummy = " & $dummy & @lf & @lf & 'if not $dummy="\\"' & @lf & @lf & 'The Values are *NOT* equal. "IF NOT..." was used, so should give "TRUE"') EndIf ExitoÝ÷ Ù8^µë-¶#§µçm¢ëÁ«¢¶©jØl¶¸§Ó¶ÞPкÚ"µÍYÝÝ[ÓY ÌÍÑ]OI][ÝÉÌLÉÌLÉ][ÝÈ[ÈÝ]X[ÛÈ Õ [SÈ] HHÝ[ÈÚ[ÝÚ]×ÉÌLÜ] ÌLÜ][ÈÈHÛÛYÈÎÌLÜ] ÌLÜ] Thanks for any suggestions, Rudi. Edited July 6, 2007 by rudi Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
Siao Posted July 6, 2007 Share Posted July 6, 2007 (edited) Yea, from Help file:When more than one operator is used in an expression the order in which things happen is controlled by operator precedence. The precedence used in AutoIt is given below. Where two operators have the same precedence the expression is evaluated left to right.From highest precedence to lowest: NOT ^ * / + - & < > <= >= = <> == AND ORMeans "Not" takes place before "Equal".Doesn't make sense logically, but that's how it is... Edited July 6, 2007 by Siao "be smart, drink your wine" Link to comment Share on other sites More sharing options...
rudi Posted July 6, 2007 Author Share Posted July 6, 2007 consider...if not $dummy="C_" Then(not $dummy) = "C_"not ($dummy = "C")Lar.Ah! So my mistake was to consider that a "if not" == "!="On my way to check this. Thanks a lot for your FAST reply!!Regards, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
rudi Posted July 6, 2007 Author Share Posted July 6, 2007 Ah! So my mistake was to consider that a "if not" == "!="Yes! With brackets it's working as expected.What about adding the "!=" operator? Basically I wanted to use my faulty expression as I do not like "<>"...Thanks once more, Rudi. Earth is flat, pigs can fly, and Nuclear Power is SAFE! Link to comment Share on other sites More sharing options...
NELyon Posted July 6, 2007 Share Posted July 6, 2007 OMG! The autoit box broke again when he edited his first post. Look at the bottom of the OP's Autoit box! PS: I agree that != would make things easier. Link to comment Share on other sites More sharing options...
RDSchaefer Posted July 7, 2007 Share Posted July 7, 2007 OMG! The autoit box broke again when he edited his first post. Look at the bottom of the OP's Autoit box!PS: I agree that != would make things easier.Have we forgotten about "<>" ?Ralph 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