Navigation: thinBasic Modules > Core > General > SizeOf |
|
Description
Returns the size of a variable or a variable type.
Syntax
n = SizeOf (Variable)
Returns
Number
Parameters
Name |
Type |
Optional |
Meaning |
Variable |
Any |
No |
Any variable name or variable type |
Remarks
Variable can be a single variable name or an UDT or any UDT element in any nested UDT structures.
Variable types can be any of the supported thinBasic variable types.
Expressions will generate a runtime error. It can be possible to understand expression size at runtime but it has be decided to leave this limitation.
Restrictions
See also
Examples
USES "console"
Alias console_writeline As WL
Dim sFormat As String = "#####"
wl "Some basic data size"
wl repeat$(70, "-")
wl USING$("Size of BYTE is: " & sFormat, SIZEOF(Byte) )
wl USING$("Size of INTEGER is: " & sFormat, SIZEOF(Integer) )
wl USING$("Size of WORD is: " & sFormat, SIZEOF(WORD) )
wl USING$("Size of DWORD is: " & sFormat, SIZEOF(DWORD) )
wl USING$("Size of LONG is: " & sFormat, SIZEOF(Long) )
wl USING$("Size of QUAD is: " & sFormat, SIZEOF(QUAD) )
wl USING$("Size of SINGLE is: " & sFormat, SIZEOF(Single) )
wl USING$("Size of DOUBLE is: " & sFormat, SIZEOF(Double) )
wl USING$("Size of EXT is: " & sFormat, SIZEOF(EXT) )
wl USING$("Size of CURRENCY is: " & sFormat, SIZEOF(Currency) )
wl USING$("Size of STRING (strings are pointers) is: " & sFormat, SIZEOF(String) )
Dim MyString As String
wl USING$("Size of MyString (empty variable) is: " & sFormat, SIZEOF(MySTRING) )
MyString = "ABCDEF"
wl USING$("Size of MyString (filled with ABCDEF) is: " & sFormat, SIZEOF(MySTRING) )
wl repeat$(70, "-")
wl "Press any key to finish"
console_waitkey
© 2004-2008 thinBasic. All rights reserved. | Version 1.7.0.0 | Web Site: http://www.thinbasic.com |