Supported data types by thinBasic programming language
thinBasic natively supports many different data types. Despite other programming languages (especially interpreted) that support only one kind of data type or very few (1 or 2 numeric and one string) thinBasic offers native support for the following data types:
- numeric integer
- BYTE (1 single byte - 8bits)
- INTEGER (2 bytes - 16bits signed)
- WORD (2 bytes - 16bits unsigned)
- LONG (4 bytes - 32bits unsigned)
- DWORD (4 bytes - 32bits unsigned)
- QUAD (8 bytes - 64bits signed)
- numeric flating point
- SINGLE (4 bytes - 32bits - 6 precision digits)
- DOUBLE (8 bytes - 64bits - 16 precision digits)
- EXTENDED (10 bytes - 80bits - 18 precision digits)
- CURRENCY (8 bytes - 64bits - 4 precision digits)
- Strings
- fixed string: STRING * n
- fixed asciiz string: ASCIIZ * n
- dynamic strings: STRING (up to 2Gb dynamically allocated)
- UDT: user defined types (or structures)
- TYPE/END TYPE
- any complexity, any nested level (UDT inside UDT)
- any numeric, string, other UDT or UNION data type (expect dynamic strings) can be used as UDT element
- UNIONS
- defined exactly as UDT but all elements are sharing the same memory area up to the longest element present in the UNION
- VARIANT
- Variant is a special data type that can contains most of the above data value.
Usually Variants variables are used to deal with COM objects but in thinBasic they can be used as standard variables.
There are special functions that can be used to determine what kind of data is stored into a specific Variant.
Of course arrays (up to 3 dimensions) can be created for all the above data types.
This can be a complication at first sight but in reality is not:
- if you just need to deal with numers (whatever they are), just use Extended and will go perfect
- if you just need to deal with strings (whatever they are), just use dynamic strings and all will be perfect
thinBasic will make all the conversions for you when using language keywords.
But if you need more complexity, for example calling external functions (inside external DLLs) or dealing with windows API, than you have all the types you need.
And what when you will work with more typed languages like C or C++ or Java? You will be already familiar with all those types and no big problems.
Bookmarks