In AutoIt there is only one datatype called a Variant. A variant can contain numeric or string data and decides how to use the data depending on the situation it is being used in. For example, if you try and multiply two variants they will be treated as numbers, if you try and concatenate (join) two variants they will be treated as strings.
10 * 20 equals the number 200 (* is used to multiply two numbers)
10 * "20" equals the number 200
"10" * "20" equals the number 200
10 & 20 equals the string "1020" (& is used to join strings)
If a string is used as a number, an implicit call to Number() function is done. So if it doesn't contain a valid number, it will be assumed to equal 0. For example,
10 * "fgh" equals the number 0.
If a string is used as a boolean and it is an empty string "" , it will be assumed to equal False (see below). For example,
NOT "" equals the Boolean true.
Numbers can be standard decimal numbers like 2, 4.566, and -7.
Scientific notation is also supported; therefore, you could write 1.5e3 instead of 1500.
Integers (whole numbers) can also be represented in hexadecimal notation by preceding the integer with 0x as in 0x409 or 0x4fff (when using hex notation only 32-bit numbers are valid).
Strings are enclosed in double-quotes like "this". If you want a string to actually contain a double-quote use it twice like:
"here is a ""double-quote"" - ok?"
You can also use single-quotes like 'this' and 'here is a ' 'single-quote' ' - ok?'
You can mix quote types to make for easier working and to avoid having to double-up your quotes to get what you want. For example if you want to use a lot of double-quotes in your strings then you should use single-quotes for declaring them:
'This "sentence" contains "lots" of "double-quotes" does it not?'
is much simpler than:
"This ""sentence"" contains ""lots"" of ""double-quotes"" does it not?"
When evaluated, strings can have Env variables or Var variables substitution according to Opt() function definition.
Booleans are logical values. Only two Boolean values exist: true and
They can be used in variable assignments, together with the Boolean operators and, or and not.
$Boolean1 = true
$Boolean2 = false
$Boolean3 = $Boolean1 AND $Boolean2
This will result in $Boolean3 being false
$Boolean1 = false
$Boolean2 = not $boolean1
This will result in $Boolean2 being true
If Boolean values are used together with numbers, the following rules apply:
A value 0 will be equal to Boolean false
Any other number value will be equal to Boolean true
$Number1 = 0
$Boolean1 = true
$Boolean2 = $Number1 and $Boolean1
This will result in $Boolean2 being false
If you use arithmetics together with Boolean values (which is not advisable!), the following rules apply:
A Boolean true will be converted into the numeric value 1
A Boolean false will be converted into the numeric value 0
$Boolean1 = true
$Number1 = 100
$Number2 = $Boolean1 + $Number1
This will result in $Number2 to be the numeric value 101
If you use strings together with Boolean values, they will be converted as follows:
A Boolean true will be the string value "True"
A Boolean false will be the string value "False"
$String1="Test is: "
$String2=$String1 & $Boolean1
This will result in $String2 being the string value "Test is: True"
The other way around however is different. When you use string comparisons with Boolean values, the following rules apply:
Only an empty string ("") will be a Boolean false
Any other string values (including a string equal "0") will be a Boolean true
Binary type can store any byte value. they are converted in
hexadecimal representation when stored in a string variable.
$bin = Binary("abc")
$str = String($bin) ; "0x616263"
Pointer types store a memory address which is 32bits or 64bits depending on if the 32bit or 64 bit of AutoIt is used. They are converted to hexadecimal representation when stored in a string variable. Window handles (HWnd) as returned from WinGetHandle are a pointer type.
The following table shows the internal variant datatypes and their ranges.
|Data Sub-type||Range and Notes|
|Int32||A 32bit signed integer number.|
|Int64||A 64bit signed integer number|
|Double||A double-precision floating point number.|
|String||Can contain strings of up to 2147483647 characters.|
|Binary||Binary data, can contain up to 2147483647 bytes.|
|Pointer||A memory address pointer. 32bit or 64bit depending on the version of AutoIt used.|
Some functions in AutoIt only work with 32 bit numbers (e.g. BitAND) and are converted automatically - these functions are documented where required.