Code: Select all
DefType.w foo
Debug SizeOf(foo)
Debug SizeOf(w)
End
Code: Select all
DefType.w foo
Debug SizeOf(foo)
Debug SizeOf(w)
End
Code: Select all
DefType.w w,foo
Debug SizeOf(foo)
Debug SizeOf(w)
EndCode: Select all
DefType.w foo
Debug SizeOf(foo)
Debug SizeOf(w)
EndCode: Select all
DefType.w fooWhich i guess should be re-edited as now it can get the size variables.The SizeOf command can be used to find out the size of any complex Structure (it does not work on the simple built-in types such as word and float), Interface or even variables.

Don't make me hit you with a stick, or something worse.Kale wrote:Of course this will not compile, the var 'w' has not been declared.
Code: Select all
Structure blah
a.w
b.w
EndStructure
Debug SizeOf(blah)
End

Because I don't want my code littered with random 1, 2 and 4 values when SizeOf(type) will give it much more meaning. I know there are constants #SIZEOF_B but that's a bit crappy compared to everything being able to be done with SizeOf().Kale wrote:Only user defined types. Why would you need to know how big built-in types are, you already know?Types are supported by SizeOf.
Code: Select all
Structure blah
a.w
b.w
EndStructure
Debug SizeOf(blah\a)
End

Name Extension Memory consumption Range
Byte .b ->1 byte in memory -128 to +127
Word .w ->2 bytes in memory -32768 to +32767
Long .l -> 4 bytes in memory -2147483648 to +2147483647
Float .f -> 4 bytes in memory unlimited (see below)
String .s -> length of the string + 1 Up to 65536 characters

Code: Select all
POINT.l
Debug SizeOf(POINT)
Sounds ok, should be coherent, but i have an idea; what about use this syntax for SizeOf() ?:What should do the compiler do if a variable is named like a type ? I think than Type should have an higher priority. Sounds ok ?
Code: Select all
f.f=4.5
debug SizeOf(.f);<-- this if we want know size of floats
debug SizeOf(f);<-- this in case we need to know the size of variable