dark_jedi Posted July 20, 2006 Posted July 20, 2006 (edited) how do string and number comparisons work such as $a="foobar" $b=1 if not $a==$b Then MsgBox(0,"no","foobar does not==1") if $a==$b Then MsgBox(0,"yes","foobar==1") which by the way when i run the script neither if statement gets executed which seems impossible. Edited July 20, 2006 by dark_jedi
death pax Posted July 20, 2006 Posted July 20, 2006 (edited) $a="foobar" $b=1 if $a==$b Then MsgBox(0,"","Matched") else MsgBox(0,"","Didnt Match") endif oÝ÷ ÚÚºÚ"µÍÌÍØOI][ÝÙÛØ][ÝÂÌÍØLBY ÌÍØIÉÝÉÌÍØ[ÙÐÞ ][ÝÉ][ÝË ][ÝÑYÌÎNÝX]Ú ][ÝÊB[ÙBÙÐÞ ][ÝÉ][ÝË ][ÝÓX]ÚY ][ÝÊB[Y <> (not equal to) is for comparisons guess i don't know exactly what you are asking Edited July 20, 2006 by death pax
dark_jedi Posted July 20, 2006 Author Posted July 20, 2006 (edited) first of all the code below outputs the same thing as if you not the if statement $a="foobar" $b=1 if $a==$b Then MsgBox(0,"","Matched") else MsgBox(0,"","Didnt Match") endif second of all how do you not understand what im asking... how are the string and number being compared? most languages will not allow you to compare a string and number. I read in help file that a string will default to 0 in certain situations or take the first numbers if they are present. Edited July 20, 2006 by dark_jedi
Developers Jos Posted July 20, 2006 Developers Posted July 20, 2006 which by the way when i run the script neither if statement gets executed which seems impossible.You use wrong logic in your If Not statement. Should be: $a="foobar" $b=1 if not ($a==$B) Then MsgBox(0,"no","foobar does not==1") if $a==$b Then MsgBox(0,"yes","foobar==1") 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.
Briegel Posted July 20, 2006 Posted July 20, 2006 You use wrong logic in your If Not statement.Where can I read which is the right logic for 'If Not'?I searched in the help file and the forum, but I didn't find anything.For this reason I write my scripts without 'If Not'.
Developers Jos Posted July 20, 2006 Developers Posted July 20, 2006 Where can I read which is the right logic for 'If Not'?I searched in the help file and the forum, but I didn't find anything.For this reason I write my scripts without 'If Not'. I shown it in the post but let me explain a bit more:When you take this statement:if not 5=6 Then MsgBox(0,"test1","test1")It will resolve "Not 5" first giving this statement: if False=6 Then MsgBox(0,"test1","test1")When you take this statement:if not (5=6) Then MsgBox(0,"test2","Test2")It will resolve "5=6 first giving this statement: if not (False) Then MsgBox(0,"test2","Test2")See the difference? 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.
MHz Posted July 20, 2006 Posted July 20, 2006 (edited) Where can I read which is the right logic for 'If Not'?I searched in the help file and the forum, but I didn't find anything.For this reason I write my scripts without 'If Not'. JdeB added braces to force $a==$b rather then If Not $a as "Operator precedence" takes place with Not being evaluated 1st without the braces used in the above code.http://www.autoitscript.com/autoit3/files/...g_operators.htm Edited July 20, 2006 by MHz
Briegel Posted July 20, 2006 Posted July 20, 2006 @JdeB and MHz,thanks for patience and explanations (I understood).I know the section about operators in the help file. But I didn't find 'For using "If Not" you have to bracket the expression' or something like this there (maybe I'm the only).
MHz Posted July 20, 2006 Posted July 20, 2006 Briegel,Review of operater precedence as you still seem unsure?From highest precedence to lowest: NOT ^ * / + - & < > <= >= = <> == AND ORNot has highest precedence. Any value next to Not will be evaluted 1st. Not "If Not", just "Not" is the concern.The examples below as quoted on the help page are quite good at explaining how to use braces to change precedence of how you want which expressions to be evalutated first.First precedence of evaluation in boldIf Not 0 = 1 Thenas above Not 0 becomes 1.Now to force a change of precedence, use braces.If Not (0 = 1) Thenas above, 0=1 will be evaluted before Not does it's evaluation. A precedence change done with braces.Hope alittle clearer.
Briegel Posted July 20, 2006 Posted July 20, 2006 Thanks MHz, you're very tirelessly. I really understood. But it is a difference between reading and understanding something. I know I still have much to learn to code with AutoIt and ... english. :"> These are enough reasons for me to be a member in this forum. again thanks
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