Jump to content

Boolens: Does not work as expected in case of strings

Recommended Posts

Hello, I am in a little confusion with Boolens :unsure:, Here is my code:

ConsoleWrite(("Something" = "Samething") & @CRLF) ; False
ConsoleWrite((Not "Something" = "Samething") & @CRLF) ; True
ConsoleWrite((Not False) & @CRLF) ; True

I have commented the results which I expected, but the expression in the 2nd line is not working as expected :unsure:, Can anyone explain to me?

SciTE Output:

>"C:\Program Files (x86)\AutoIt3\SciTE\..\AutoIt3.exe" "C:\Program Files (x86)\AutoIt3\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.au3" /run /prod /ErrorStdOut /in "C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3" /UserParams    
+>20:26:24 Starting AutoIt3Wrapper v.15.920.938.0 SciTE v.   Keyboard:00004009  OS:WIN_81/  CPU:X64 OS:X64    Environment(Language:0809)
+>         SciTEDir => C:\Program Files (x86)\AutoIt3\SciTE   UserDir => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE\AutoIt3Wrapper   SCITE_USERHOME => C:\Users\TheDcoder\AppData\Local\AutoIt v3\SciTE
>Running AU3Check (  from:C:\Program Files (x86)\AutoIt3  input:C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3
+>20:26:24 AU3Check ended.rc:0
>Running:(\Program Files (x86)\AutoIt3\autoit3.exe "C:\Users\TheDcoder\Desktop\AIO AutoIt Test Script.au3"    
--> Press Ctrl+Alt+Break to Restart or Ctrl+Break to Stop
+>20:26:24 AutoIt3.exe ended.rc:0
+>20:26:24 AutoIt3Wrapper Finished.
>Exit code: 0    Time: 0.8031

Thanks in Advance, TD :)

EasyCodeIt - A cross-platform AutoIt implementation - Fund the development! (GitHub will double your donations for a limited time)

DcodingTheWeb Forum - Follow for updates and Join for discussion

Link to comment
Share on other sites

Operators precedence forces the evaluation of Not 'Something' and that then forces conversion of the string to a number 'Something' evaluates to zero then Not 0 evaluates to anything distinct from zero, say 1, but then 1 = 'Samething' is False (since that string also evaluates to 0).

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 here
RegExp tutorial: enough to get started
PCRE 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)

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...