JohnOne Posted May 19, 2010 Share 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. Link to comment Share on other sites More sharing options...
water Posted May 19, 2010 Share 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 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
notsure Posted May 19, 2010 Share 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 Link to comment Share on other sites More sharing options...
notsure Posted May 19, 2010 Share Posted May 19, 2010 too late Link to comment Share on other sites More sharing options...
JohnOne Posted May 19, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
water Posted May 19, 2010 Share Posted May 19, 2010 Glad to be of service! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
MvGulik Posted May 19, 2010 Share 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 ... Link to comment Share on other sites More sharing options...
JohnOne Posted May 19, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
MvGulik Posted May 19, 2010 Share 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 ... Link to comment Share on other sites More sharing options...
ShawnW Posted May 19, 2010 Share 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 Link to comment Share on other sites More sharing options...
MvGulik Posted May 19, 2010 Share 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 ... Link to comment Share on other sites More sharing options...
notsure Posted May 19, 2010 Share 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 Link to comment Share on other sites More sharing options...
JohnOne Posted May 20, 2010 Author Share 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. 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