Returns the offset of a field within a type.
Syntax
Usage
result = OffsetOf( typename, fieldname )
Parameters
typename
fieldname
Name of the field as defined within the type.
Description
OffsetOf will return the location fieldname as offset in bytes from the beginning of typename.
Example
Type MyType
x As Single
y As Single
Union
b As Byte
i As Integer
End Union
End Type
Print "OffsetOf x = "; OffsetOf(MyType, x)
Print "OffsetOf y = "; OffsetOf(MyType, y)
Print "OffsetOf b = "; OffsetOf(MyType, b)
Print "OffsetOf i = "; OffsetOf(MyType, i)
Output
OffsetOf x = 0
OffsetOf y = 4
OffsetOf b = 8
OffsetOf i = 8
Dialect Differences
- Not available in the -lang qb dialect unless referenced with the alias __Offsetof.
Differences from QB
See also