Jump to content

"=" versus "=="


Recommended Posts

Sorry if this has been asked 1,000 times already, but I cannot enter these symbols into the search feature on the forums and the Help File has very little to say about these operators.

When would we use "==" versus "=" ? The help file seems to imply that the only difference between them is that "==" is case sensitive, is that entirely accurate? I bring this up because of a piece of code that I have been using in many of my scripts suddenly did not work in a new script, and after hours of debugging, I decided to try using "==" instead of "=" and the script ran perfectly.

I will post the example at the bottom of thread, but the short of it is that I was looping and testing for a String value, and when a certain string appears then stop the loop. The below example works if the string value does/does not contain a space (" "), whereas previously when I used "=" it only worked as long as there was no space (" ") in the string. Feedback please?

Thanks in Advance.

Help File:

= Tests if two values are equal (case insensitive if used with strings)

== Tests if two values are equal (case sensitive if used with strings)

Func Find_Table_in_Browser ($oIE, $iEnd)
    ;Get TableData i.e. like a List of Usernames
    $iCC = 0
    Do
        $oTable = _IETableGetCollection ($oIE, $iCC)
        $aTableData = _IETableWriteToArray ($oTable)
        $iCC+=1
    Until $aTableData[0][0] == $iEnd ; previously was just "="
    Return $aTableData
EndFunc;<==Find_Table_in_Browser()
Link to comment
Share on other sites

== is to check whether something is true in C++, autoit doesn't really need this. A regular = will check and assign values

= is to assign values to a variable

F@m!ly Guy Fr33k! - Avatar speaks for itself__________________________________________________________________________________________ite quotes... - Is your refrigerator running? If it is, It probably runs like you...very homosexually - Christians don't believe in gravity - Geeze Brian where do you think you are, Payless?- Show me potato Salad!__________________________________________________________________________________________Programs available - Shutdown timer[indent][/indent]
Link to comment
Share on other sites

Thanks

Then how do we account for the fact that using "==" fixed my script?

Apparently it is needed for something because there are many examples in the helpfile that uses them and other scripts on this site. I don't exactly what the difference is either but would like to know also.

EndFuncAutoIt is the shiznit. I love it.
Link to comment
Share on other sites

Unless used with a string = and == are the same.

The help file explains this fine i think.

1==1 true

"1"=="1" true

1=1 true

"a"="A" true

"a"=="A" false

It is posible that there is some sort of auto-trim used with the == version but you could try and test somthing like

Func Find_Table_in_Browser ($oIE, $iEnd)
    ;Get TableData i.e. like a List of Usernames
    $iCC = 0
    Do
        $oTable = _IETableGetCollection ($oIE, $iCC)
        $aTableData = _IETableWriteToArray ($oTable)
        $iCC+=1
    Until StringStripWS ($aTableData[0][0],8) = StringStripWS ($iEnd,8)
    Return $aTableData
EndFunc;<==Find_Table_in_Browser()

== is to check whether something is true in C++, autoit doesn't really need this.

That's not entirely true as explained above. Edited by evilertoaster
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...