See Also: SizeOfString, SizeOfWString, Data Types, Variables and Constants
SizeOfType returns the size in bytes of the specified data type. Can be used with both fundamental types and user defined struct types.
This is typically needed for passing structs to External_Function calls.
(SizeOfType( {type} ))
Where:
{type} is any of the built in fundamental types or a user defined struct type
This sample shows how to determine the size of the string data type.
Function SizeOfString
Move (SizeOfType(string)) to iSize
Function_Return iSize
End_Function
This sample shows how to determine the size of a structured data type.
Struct tPoint
Integer iXPos
Integer iYPos
End_Struct
Function SizeOf_tPoint returns Integer
Integer iSize
Move (SizeOfType(tPoint)) to iSize
Function_Return iSize
End_Function
A common mistake is to pass a variable of a particular data type instead of the data type itself. For example:
Procedure OnClick
Integer iCounter iTypeSize
Move (SizeOfType(iCounter)) to iTypeSize
End_Procedure
This code will result in compiler error 54 "Invalid symbol in expression". The corrected version of the above code is shown below, passing the data type itself:
Procedure OnClick
Integer iCounter iTypeSize
Move (SizeOfType(integer)) to iTypeSize
End_Procedure