Title : Get size of type in bytes
Author : BlitzSupport
Posted : 1+ years ago
Description : BlitzMax lets you use SizeOf on an existing variable or object, but what if you just want to check the size of a type without creating one?
For instance, I just found I needed to create a bank the size of two integers:
CreateBank (SizeOf (OOPS_HAVENT_GOT_AN_INT_HANDY) * 2)
Just do SizeOf (
Type (
Null value for type -- 0 for numbers, Null for Blitz types))... [/i]
Code : Print SizeOf (Byte (0))
Print SizeOf (Short (0))
Print SizeOf (Int (0))
Print SizeOf (Long (0))
Print SizeOf (Float (0))
Print SizeOf (Double (0))
' Bonus ball! Size of type...
' Example type/class...
Type Test
Field temp1:Int ' 4 bytes
Field temp2:Short ' 2 bytes
End Type
Print SizeOf (Test (Null))
Comments : none...