Structure is useful to define user type, and access some OS memory areas. Structures can be used
to enable faster and easier handling of data files. It is very useful as you can group into the same
object the informations which are common. Structures fields are accessed with the \ option. Structures
can be nested. Statics arrays are supported inside structures.
The optionnal Extends parameter allows to extends another structure with new fields. All fields
found in the extended structure will be available in the new structure and will be placed before
the new fields. This is useful to do basic inheritance of structures.
SizeOf can be used with structures to get the size of the structure and OffsetOf can be used to retrieve
the index of the specified field.
Please note, that in structures a static array[] doesn't behave like the normal BASIC array (defined using Dim)
to be conform to the C/C++ structure format (to allow direct API structure porting). This means that a[2] will
allocate an array from 0 to 1 where Dim a(2) will allocate an array from 0 to 2.
Example:
Structure Person
Name.s
ForName.s
Age.w
EndStructure
Dim MyFriends.Person(100)
; Here the position '0' of the array MyFriend()
; will contain one person and it's own informations
MyFriends(0)\Name = "Andersson"
MyFriends(0)\Forname = "Richard"
MyFriends(0)\Age = 32
Example: A more complex structure (Nested and static array)
Structure Window
*NextWindow.Window ; Points to another window object
x.w
y.w
Name.s[10] ; 10 Names available (from 0 to 9)
EndStructure
Example: Extended structure
Structure MyPoint
x.l
y.l
EndStructure
Structure MyColoredPoint Extends MyPoint
color.l
EndStructure
ColoredPoint.MyColoredPoint\x = 10
ColoredPoint.MyColoredPoint\y = 20
ColoredPoint.MyColoredPoint\color = RGB(255, 0, 0)