JohnOne Posted May 19, 2010 Posted May 19, 2010 (edited) I observed some odd behaviour, and just wondering why this happens? and if Im doing something wrong. If @ScriptName = "Test.au3" Then ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3" EndIf If Not @ScriptName = "Tess.au3" Then ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong" EndIf I also tried $sName = @ScriptName If $sName = "Test.au3" Then ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3" EndIf If Not $sName = "Tess.au3" Then ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong" EndIf With the same result EDIT: sorry, I guess "Not" only works with boolean type. Edited May 19, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted May 19, 2010 Posted May 19, 2010 Try this one If @ScriptName = "Test.au3" Then ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3" EndIf If Not (@ScriptName = "Tess.au3") Then ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong" EndIf My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
notsure Posted May 19, 2010 Posted May 19, 2010 Try this. $sName = @ScriptName If $sName = "Test.au3" Then ConsoleWrite(@ScriptName & @CRLF) ;writes "Test.au3" EndIf If Not ($sName = "Tess.au3") Then ConsoleWrite("Wrong" & @CRLF) ;does not write "wrong" EndIf
JohnOne Posted May 19, 2010 Author Posted May 19, 2010 Ahh ! Thank you very kindly gentlemen. Its little things like this, that get me all the time. AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
water Posted May 19, 2010 Posted May 19, 2010 Glad to be of service! My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
MvGulik Posted May 19, 2010 Posted May 19, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
JohnOne Posted May 19, 2010 Author Posted May 19, 2010 (edited) Nope. Not a bad point of view. But "Not $a=$b" => "(Not $a)=$b" Now Im a little more confused, I came to the conclusion that autoit internally converts the value to boolean type if it is not already of that type. The following confirmed it (for me anyway) $100 = 100 $text ="text" $not100 = (Not $100) $Nottext = (Not $text) ConsoleWrite($not100 & @CRLF & $Nottext & @CRLF) Output False False Edited May 19, 2010 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
MvGulik Posted May 19, 2010 Posted May 19, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
ShawnW Posted May 19, 2010 Posted May 19, 2010 (edited) autoit DOES convert to a boolean value but the problem was the order of operations. If Not @ScriptName = "Tess.au3" Then is the same as If (Not @ScriptName) = "Tess.au3" Then because the Not applies 1st. Since the @ScriptName is a string that when converted to Boolean is True (any non-zero or non-empty string is True) This basically evaluated to If Not True = "Tess.au3" Then then If Not True = True Then in other words If False = True Then When you change the order of operations by saying If Not (@ScriptName = "Tess.au3") Then the strings are compared first. Since they are false the operation becomes If Not (False) Then which of course is If True Then Edited May 19, 2010 by ShawnW
MvGulik Posted May 19, 2010 Posted May 19, 2010 (edited) whatever Edited February 7, 2011 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ...
notsure Posted May 19, 2010 Posted May 19, 2010 (edited) autoit DOES convert to a boolean value but the problem was the order of operations.Great post! Edited May 19, 2010 by notsure
JohnOne Posted May 20, 2010 Author Posted May 20, 2010 Yes, well explained. Thanks all, educated +1 <weary of smiley> AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans.
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