FutureBasic Logo

<<    Index    >> FutureBasic

sizeof   function



Syntax
dataSize = sizeof( { var | typeName | ptrType^ | hdlType^^ } )

Description
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
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
typeof; len; begin record; #define