Sign in to follow this  
Followers 0
Achilles

Just a little simple question...

5 posts in this topic

Well, if you read the title you go the jist of it. I'm just wondering why some people use "==" and some just use "="... I've always used "=" and it's worked fine... The helpfile says they are the same thing but then I don't see why it would include to identical ways to state something.

Piano_Man


My Programs[list][*]Knight Media Player[*]Multiple Desktops[*]Daily Comics[*]Journal[/list]

Share this post


Link to post
Share on other sites



As it also says,

= Tests if two values are equal (case insensitive if used with strings). e.g. If $var= 5 Then (true if $var equals 5)

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

So:

"Dog"="dog" is True

"Dog"=="dog" is False

Share this post


Link to post
Share on other sites

#3 ·  Posted (edited)

sorry i may be very wrong in autoit - but in c++ and vbs '=' is an assignment to a variable , and '==' is a relational operator.

IE

'variable assignment context

a = 10

(vaue 10 is put into variable 'a')

'relational operator context

if (a==10)

Do correct me though if im wrong - im not up to speed with autoit as yet.

EDIT: As im not up tp speed you should probably not listen to me hahaha. Read above for a better informed post.

Edited by amfony

Share this post


Link to post
Share on other sites

Do correct me though if im wrong - im not up to speed with autoit as yet.

It will work like you described, but not for that reason. Expressions are always rendered boolean for the if statement.

With =, AutoIt lets the context determine if an expression is an assignment or a comparison.

$var = "one" assigns "one" to $var

Consider:

ConsoleWrite((1=1)+3 & @cr)

ConsoleWrite((1=1) & 3)

Outputs:

4

True3

You'd do well to experiment a little, and read up on "Operators" in the help file. I know a lot of people don't like help files, but this is a good one - well-designed, consistant, and genuinely useful. Honestly, I wish more help files were like it!

Share this post


Link to post
Share on other sites

I know a lot of people don't like help files, but this is a good one - well-designed, consistant, and genuinely useful. Honestly, I wish more help files were like it!

I couldn't agree more. The Autoit helpfile is awesome. I'm not really much of a coder, but the help file is so well written, I've hardly had to ask any questions at all, and I've been able to do some really cool stuff all on my own. :P

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