Although PureBasic is a procedural language it provides support for object-oriented programming through the use of interfaces.
Consider this example which illustrates how to create a rectangle object of with the methods Draw() and Delete():
;/ Declare object properties
Structure Rectangle_
*vt.i
x1.i
x2.i
y1.i
y2.i
EndStructure
;/ Define object methods
Procedure Draw_Rectangle(*this.Rectangle_)
EndProcedure
Procedure Delete_Rectangle(*this.Rectangle_)
EndProcedure
;/ Class interface
Interface Rectangle
Draw()
Delete()
EndInterface
Procedure New_Rect(x1.l, x2.l, y1.l, y2.l)
*Rect.Rectangle_ = AllocateMemory(SizeOf(Rectangle_))
If *Rect
*Rect\vt = ?RectVT
*Rect\x1 = x1
*Rect\x2 = x2
*Rect\y1 = y1
*Rect\y2 = y2
EndIf
ProcedureReturn *Rect
EndProcedure
;/ Create a new object
Rect.Rectangle = New_Rect(0, 10, 0, 20)
;/ Call object methods
Rect\Draw()
Rect\Delete()
;/ Function VTable pointers
DataSection
RectVT:
Data.i @Draw_Rectangle()
Data.i @Delete_Rectangle()
EndDataSection
Detailed information can be found in Stephen Rodriguez's OOP tutorial:
http://www.purecoder.net/oop.zip
Additionally, there are various OOP precompilers which can automate much of this by encapsulating the process in familiar keyword blocks such as "Class":
http://www.purebasic.fr/english/viewtopic.php?f=14&t=30236
http://www.purebasic.fr/english/viewtopic.php?f=27&t=30774