Futurebasic/Language/Reference/sizeof
SIZEOF
[edit | edit source]Syntax
[edit | edit source]dataSize = SIZEOF({var|typeName|ptrType^|hdlType^^})
Description
[edit | edit source]This function returns the number of bytes of memory allocated for a particular variable var
, or the number of bytes allocated for each variable of a particular specified type.
If you specify typeName
, it should either be the name of a type defined previously in your program (in a BEGIN RECORD
statement or a #DEFINE
statement), or the name of one of FutureBasic's built-in types (such as INT
, LONG
, RECT
, etc.). SIZEOF
returns the size of a variable of that type.
If you specify ptrType^
, then ptrType
should be the name of a type which was previously declared to be a pointer to some other type (in a #DEFINE
statement). In this case, SIZEOF
returns the size of the type that ptrType
points to. Note that if you omit the "^
" symbol, SIZEOF(ptrType)
just returns the size of a pointer variable (usually 4).
If you specify hdlType^^
, then hdlType
should be the name of a type which was previously declared to be a handle to some other type (in a #DEFINE
statement). In this case, SIZEOF
returns the size of the type referenced by hdlType
. Note that if you omit the "^^
" symbols, SIZEOF(hdlType)
just returns the size of a handle variable (usually 4).
Note
[edit | edit source]SIZEOF(stringVar$)
returns the number of bytes reserved in memory for the string variable stringVar$
.
This is not the same thing as LEN(stringVar$)
.
If a variable handleVar
contains the handle to a relocatable block (of a possibly unknown type), you can use the Toolbox function GETHANDLESIZE
to determine the size of the block.
See Also
[edit | edit source]TYPEOF; LEN; BEGIN RECORD; #DEFINE