Gianni Posted September 8, 2019 Posted September 8, 2019 Shouldn't the last 2 lines give as result false instead of True? $value = 1 ConsoleWrite( $value = Null) ConsoleWrite(@CRLF) ConsoleWrite( $value > Null) ConsoleWrite(@CRLF) ConsoleWrite( $value < Null) ConsoleWrite(@CRLF) ConsoleWrite( $value >= Null) ConsoleWrite(@CRLF) ConsoleWrite( $value <= Null) ConsoleWrite(@CRLF) Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
water Posted September 8, 2019 Posted September 8, 2019 (edited) Null evaluates to 0 in mathematical operations (according to the help file). I can't test at the moment but I would expect: $value = 1 ConsoleWrite( $value = Null) ; False ConsoleWrite(@CRLF) ConsoleWrite( $value > Null) ; True ConsoleWrite(@CRLF) ConsoleWrite( $value < Null) ; False ConsoleWrite(@CRLF) ConsoleWrite( $value >= Null) ; True ConsoleWrite(@CRLF) ConsoleWrite( $value <= Null) ; False ConsoleWrite(@CRLF) What do you get? Edited September 8, 2019 by water 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
Gianni Posted September 8, 2019 Author Posted September 8, 2019 I get this result: False False False True True Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
water Posted September 8, 2019 Posted September 8, 2019 (edited) I think the problem is caused by the Statement ($value operator Null) not being a mathematical operation. It is a comparison. Null is not a value (but a keyword) so you can't compare it this way and assume it is evaluated to 0. I tested: $value = 1 $Null = Null ; $Null = "" $Null = 0 $Null = Null $Null = Int(Null) ConsoleWrite($value = $Null) ; Expected: False Result: False Result: False Result: False Result: False ConsoleWrite(@CRLF) ConsoleWrite($value > $Null) ; Expected: True Result: True Result: True Result: False Result: True ConsoleWrite(@CRLF) ConsoleWrite($value < $Null) ; Expected: False Result: False Result: False Result: False Result: False ConsoleWrite(@CRLF) ConsoleWrite($value >= $Null) ; Expected: True Result: True Result: True Result: True Result: True ConsoleWrite(@CRLF) ConsoleWrite($value <= $Null) ; Expected: False Result: False Result: False Result: True Result: False ConsoleWrite(@CRLF & @CRLF) Edited September 8, 2019 by water 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
Gianni Posted September 8, 2019 Author Posted September 8, 2019 I was hoping to be able to use it in comparisons too, but as also your tests show, it's better to avoid ... however I would have expected an error in response to that use rather than these "strange" results. Thank you @water for your reply. Chimp small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....
water Posted September 8, 2019 Posted September 8, 2019 You can. Use function IsKeyword. 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
jchd Posted September 8, 2019 Posted September 8, 2019 (edited) Granted, Null has been introduced in AutoIt only lately, yet it's kinda half-backed, maybe due to the variant nature under AutoIt variables. Idealy, Null literally means "I don't know the value", something completely distinct from zero, empty string, False, an empty array, etc. So the correct way to handle any operation involving Null is to consistantly return Null. That's how it behaves in SQL for instance, since SQL explicitely uses ternary logic (True, False, Null). Anyway, in light of the intended meaning of Null, it doesn't make sense to try to compare this keyword to anything. You should get 5 times Null as result of your code. Indeed, not returning Null is wrong, else one would have to devise a logical way to compare any datatype to Null and return something sensible. That's impossible: Null vs some object ??? Null vs Default ??? Null vs 3.1415926 ??? Null vs False ??? Some may consider debatable whether not returning Null when it's part of an operation is an actual bug, but from my window it clearly is, because Null is currently inconsistent: expandcollapse popupConsoleWrite(Null < 0) ConsoleWrite(@CRLF) ConsoleWrite(Null = 0) ConsoleWrite(@CRLF) ConsoleWrite(Null > 0) ConsoleWrite(@CRLF) ConsoleWrite(Null < "") ConsoleWrite(@CRLF) ConsoleWrite(Null = "") ConsoleWrite(@CRLF) ConsoleWrite(Null > "") ConsoleWrite(@CRLF) ConsoleWrite(Null < False) ConsoleWrite(@CRLF) ConsoleWrite(Null = False) ConsoleWrite(@CRLF) ConsoleWrite(Null > False) ConsoleWrite(@CRLF) ConsoleWrite(Null < True) ConsoleWrite(@CRLF) ConsoleWrite(Null = True) ConsoleWrite(@CRLF) ConsoleWrite(Null > True) ConsoleWrite(@CRLF) ConsoleWrite(Null < Default) ConsoleWrite(@CRLF) ConsoleWrite(Null = Default) ConsoleWrite(@CRLF) ConsoleWrite(Null > Default) ConsoleWrite(@CRLF) If Null Then ConsoleWrite("Null is True" & @LF) If Not Null Then ConsoleWrite("Here Null behaves like False" & @LF) Also Null = Null should return Null as well. Edited September 9, 2019 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)
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