Jump to content

Help file, language reference, operators


rudi
 Share

Recommended Posts

Hi.

for the "==" operator the language reference is telling:

Tests if two strings are equal. Case-sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used if string comparisons need to be case-sensitive.

 

This operator "==" can also be used to check, if a value is really "true" or just not 0 / false:

 

; Autoit v 3.3.14.5

Dim $aValues[9] = [True, False, "Just-some-string",-2,-1,0,1,2,100]

For $CheckThis In $aValues
    ConsoleWrite("-------------- " & $CheckThis & " ----------------" & @CRLF)
    If $CheckThis = True Then
        ConsoleWrite("It's true, when using one ""="" doing the compare." & @CRLF)
        If $CheckThis == True Then
            ConsoleWrite("still true, when using two ""=="" doing the compare." & @CRLF)
        Else
            ConsoleWrite("It's *NO MORE* true, when using two ""=="" doing the compare!" & @CRLF)
        EndIf
    Else
        ConsoleWrite("It's *NOT* true" & @CRLF)
    EndIf
Next
-------------- True ----------------
It's true, when using one "=" doing the compare.
still true, when using two "==" doing the compare.
-------------- False ----------------
It's *NOT* true
-------------- Just-some-string ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!
-------------- -2 ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!
-------------- -1 ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!
-------------- 0 ----------------
It's *NOT* true
-------------- 1 ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!
-------------- 2 ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!
-------------- 100 ----------------
It's true, when using one "=" doing the compare.
It's *NO MORE* true, when using two "==" doing the compare!

 

Regards, Rudi.

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

...case sensitivity or exactness. Do you really feel that the help file needs to be explicit in regards of non-string operations ?, it is implied. Anyone with experience knows.
If to amend the help file, how would you phrase it @rudi

Follow the link to my code contribution ( and other things too ).
FAQ - Please Read Before Posting.
autoit_scripter_blue_userbar.png

Link to comment
Share on other sites

From my personal view, it comes from other other programming languages.  Most novice programmers don't bother to look at those simplest operations, they put codes together and if it works without error, it must be right...

Link to comment
Share on other sites

  • 2 weeks later...

IMHO precise documentation is always a very valuable thing.

 

To be able to tell if a result value is really TRUE or just "not zero" might be helpful. Not much extra text, pointing out the difference clearly.

Tests if two strings are equal. Case-sensitive. The left and right values are converted to strings if they are not strings already. This operator should only be used if string comparisons need to be case-sensitive. Testing boolean with "$Value == TRUE" will only match, if the $Value really is TRUE, not just different from FALSE / 0, as "=" does.

Never mind, just my 2 cent 😉

Earth is flat, pigs can fly, and Nuclear Power is SAFE!

Link to comment
Share on other sites

34 minutes ago, rudi said:

Testing boolean with "$Value == TRUE" will only match, if the $Value really is TRUE,

This is a direct, obvious consequence of what's already stated just above in the help file as it is right now:

34 minutes ago, rudi said:

The left and right values are converted to strings if they are not strings already.

Assuming $value = (1 = 1), that is $value = True, we get:

VarGetType($Value) : 'Bool' which implies that it has to be converted to a string
String($Value) -> 'True'

Same for the boolean constant TRUE:
String(TRUE) -> 'True'

So your comparison boils down to:
'True' == 'True'
which is trivially True.

 

I don't see what's unclear in the current statement about ==

Edited 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 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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...