AutoIt (Datatypes)

From The Ultimate Programming Reference

Contents

[edit] Variant

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.



[edit] Numbers

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).



[edit] Strings

Strings are enclosed in double-quotes like "this". If you want a string 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?"



[edit] Datatype Ranges

The following shows the range of values that a variant datatype can hold.

[edit] 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)

[edit] String

Can contain strings of up to 2 billion characters.


Some functions in AutoIt only work with 32 bit numbers

Personal tools