Jump to content
Sign in to follow this  

Question about variable datatype

Recommended Posts



I have a question about the variable datatype.

I know that AutoIT has only one datatype called "Variant".

So, wich is the correct expression I have to use in the following situation

1) If $var == 100 Then ...


2) If $var == "100" Then ...


Share this post

Link to post
Share on other sites

depends if you mix number with string or not ;)

i learned hardway

related thread

If your $var is numeric tupe then its best not to compare it to "100"

Edited by bogQ

TCP server and client - Learning about TCP servers and clients connection
Au3 oIrrlicht - Irrlicht project
Au3impact - Another 3D DLL game engine for autoit. (3impact 3Drad related)

There are those that believe that the perfect heist lies in the preparation.
Some say that it’s all in the timing, seizing the right opportunity. Others even say it’s the ability to leave no trace behind, be a ghost.


Share this post

Link to post
Share on other sites

Tanks bogQ.

I red your post and I undestood that if I use a mathematical operator all the value are converted in numbers by AutoIT engine.

The == operator, using numbers, has the same effect as the = operators.

Regarding the $var in my example, it can be a number if I make a direct assign (e.g. $var = 100) but it can be a string if I read this value in a text file (e.g. $var = FileReadLine... ) and so on.

So my conclusion is:

Regardless the way you assign the variable value, the datatype is converted automatically by the AutoIT engine depending the considered expression.

Are my conclusion correct?

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