Sign in to follow this  
Followers 0
Radiance

Comparing any string to 0

5 posts in this topic

Hey all,

I'm having some major lack of understanding here.

$Var = 0
$String = "test"
MsgBox(0, "", $Var = $String)

 

Why is this True? Please explain.

Share this post


Link to post
Share on other sites



This is because you are comparing numerically and a string is equal to zero.

To do a string compare you need to use ==

Jos

1 person likes this

Visit the SciTE4AutoIt3 Download page for the latest versions        Beta files                                                          Forum Rules
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Share this post


Link to post
Share on other sites

To do a string compare you need to use ==

 

Is this the same like using String() on both items you are comparing?

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

Yes (well almost). The == operator also tests for case sensitivity in strings, and that's the difference.

Edited by czardas
1 person likes this

Share this post


Link to post
Share on other sites

==

I've never even seen that in any script before.

Thank you both for your answers.

Share this post


Link to post
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
Sign in to follow this  
Followers 0