The advantages of using oo methods to make dll's should become fairly obvious
1) No Global vars
2) makes it easier to develop and test the code
3) makes it easier to use and maintain
4) the code is dll ready
5) you only need to export an objects constructor to use from a dll
6) protects your code from unauthorized use, without the interface your codes more or less a mystery
The only disadvantage is getting around dll string boundary issues which means you have to return strings by their address
requiring that the client uses PeekS to get at the string. So any functions that returns a string simply returns the string by address
Code: Select all
;in a class functions return
ProcedureReturn @*this\SomeString
;in the client
PeekS(myObject\pstrGetSomeString())
For example to use the object from a dll is no different than using the code from source
copy and paste the public part of the class header then add the import
Code: Select all
;-Queue class public header copy and pasted from the class
Enumeration 1
#QueueType_Fifo
#QueueType_Lifo
EndEnumeration
;-Methods exposed
Interface Queue
Set(item.i) ;Add item into the queue
Get.i() ;Get item from the queue
SetGet.i(item.i) ;Add and Get an item from the queue
Count.i() ;Get the size of the queue
pStrAbout.i() ;pointer to string About
Free() ;free the class memory
EndInterface
;-End class public header copy and pasted from the class
;Then Add the import for the constructor
Import "queue.lib"
New_Queue(type.i)
EndImport
Here's the tutorial, it's fairly short on explanations and comments but hopefully it's enough.
Please feel free to add to it, flame it or what ever!
http://www.idlearts.com/ootutorial.zip