UEZ Posted May 28, 2010 Share Posted May 28, 2010 (edited) Do I missed something or why is $a = $b when $a="" and $b=0? Local $a = "" Local $b = 0 If $a = $b Then ConsoleWrite("equal!" & @CRLF) Else ConsoleWrite("NOT equal!" & @CRLF) EndIf It seems to be that "" is set to 0 in the memory for variable $a... BR, UEZ Edited November 8, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Juvigy Posted May 28, 2010 Share Posted May 28, 2010 (edited) One is number the other is a string. It is not good practice to compare them. You need to convert one to the other type - maybe like this: $x = Number("3.14") ;returns 3.14 @Edit. Strings beginning with letters are represented as 0 so: Local $a = "" Local $b = 0 If $a = String($b) Then ConsoleWrite("equal!" & @CRLF) Else ConsoleWrite("NOT equal!" & @CRLF) EndIf Edited May 28, 2010 by Juvigy Link to comment Share on other sites More sharing options...
UEZ Posted May 28, 2010 Author Share Posted May 28, 2010 (edited) Same when line 1 is: Local $a $a should be NUL and NUL should not be equal with 0 or? BR, UEZ Edited May 28, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
Yoriz Posted May 28, 2010 Share Posted May 28, 2010 Char = NULDec = 0Hex = 0Oct = 000Description = Null Character GDIPlusDispose - A modified version of GDIPlus that auto disposes of its own objects before shutdown of the Dll using the same function Syntax as the original.EzMySql UDF - Use MySql Databases with autoit with syntax similar to SQLite UDF. Link to comment Share on other sites More sharing options...
MvGulik Posted May 28, 2010 Share Posted May 28, 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...
UEZ Posted May 28, 2010 Author Share Posted May 28, 2010 (re)read Help page "Language Reference - Datatypes" (for starters)It should clearup a lot should of initial or basic question about AutoIt variable handling/behavior. (strings, numbers and bools)Good hint: ...If a string is used as a boolean and it is an empty string "" , it will be assumed to equal False (see below). For example, NOT "" equals the Boolean true...BR,UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ Link to comment Share on other sites More sharing options...
PsaltyDS Posted May 28, 2010 Share Posted May 28, 2010 Good hint: ...If a string is used as a boolean and it is an empty string "" , it will be assumed to equal False (see below). For example, NOT "" equals the Boolean true... Related, but not exactly what you were seeing in the OP. You used a compare operator "=" with a numeric, so a numeric compare was done. AutoIt made an attempt to recast "" as a number first, and the empty string evaluated to 0 for that operation. You could have forced string comparison with "==": ConsoleWrite("Numeric: " & ("" = 0) & @LF) ConsoleWrite(" String: " & ("" == 0) & @LF) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
UEZ Posted May 28, 2010 Author Share Posted May 28, 2010 (edited) The problem occured when I used ... If IsObj($colItems) Then For $objItem In $colItems $NW_DNS3 = $objItem.DNSServerSearchOrder(2) Next EndIf Local $DNS3 = StringStripWS($NW_DNS3, 2) Local $chk_text = 0 If $DNS3 = $chk_text Then ...$NW_DNS3 was empty because no 3rd DNS search order was not entered but If case was always true!Local $a or Local $a = "" is a string type -> "Only an empty string ("") will be a Boolean false"and thus $a = 0 -> If 0 = 0 then is always the case!Now it is clear to me! I changed $chk_text to "na" Thanks for your replies!BR,UEZ Edited May 28, 2010 by UEZ Please don't send me any personal message and ask for support! I will not reply! Selection of finest graphical examples at Codepen.io The own fart smells best! ✌Her 'sikim hıyar' diyene bir avuç tuz alıp koşma!¯\_(ツ)_/¯ ٩(●̮̮̃•̃)۶ ٩(-̮̮̃-̃)۶ૐ 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