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.
Some examples:
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 and it doesn't contain a valid number, it will be assumed to equal 0. For example,
10 * "fgh" equals the number 0.
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
false.
They can be used in variable assignments, together with the Boolean operators and,
or and not.
Examples:
$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
Example:
$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
Example:
$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"
Example:
$Boolean1=true
$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 containing "0") will be a
Boolean true
BinaryString are strings which can include Chr(0) characters. No substitution will occur as it does for Strings.
Example:The following table shows the range of values that a variant datatype can hold.
Data Sub-type | Range and Notes |
Numeric | A "double precision" number which is a 15 digit precision number in the range 1.7E-308 to 1.7E+308. (Stored internally as 8 bytes) |
String | Can contain strings of up to 2 billion characters. |
Some functions in AutoIt only work with 32 bit numbers (e.g. BitAND) and are converted automatically - these functions are documented where required.