PDA

View Full Version : Do you know: data types



ErosOlmi
03-08-2008, 21:32
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 (http://www.thinbasic.com/public/products/thinBasic/help/html/variables.htm):


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.

sidramalik100
28-04-2011, 11:20
thanks for your kindness now i am enable i can explain it thanks for your sharing it with us

peralta_mike
28-04-2011, 16:10
Is the LONG data type signed or unsigned? :confused:

Petr Schreiber
28-04-2011, 18:55
Hi,

LONG is signed. To keep the "Did you know" spirit... did you know you can use name Int32 in ThinBASIC for signed 32bit integer as well? :)

The "ununsigned" in Eros post might be double negation :p


Petr

ErosOlmi
28-04-2011, 21:28
sidramalik100 user seems making posts just for speading signature ads but because signature is only possible after making some more posts it does not appear. Anyway I will give some time and see.

Well "ununsigned" can be a neologism isn't it? :D
The problem is understanding how to use :confused:

Anyway, fixed.