Tutorial: PureBasic and the OOP

Developed or developing a new product in PureBasic? Tell the world about it.
rsts
Addict
Addict
Posts: 2736
Joined: Wed Aug 24, 2005 8:39 am
Location: Southwest OH - USA

Post by rsts »

This really looks like some interesting stuff. I've been pretty busy with some other projects the past few days but I'm looking forward to being able to spend some time digesting it.

Many thanks for your efforts in putting it all together.

cheers
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post by Dräc »

Thanks to all!
Don't hesitate to tell me possible enhancement for an easier reading of the tutorial (more explanations? Specific examples?...)
Dräc
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post by Dräc »

New update of the OOP set of instructions:

First, a simplification of the class declaration.
The implementation is the same as previous, but the Init_Mbers : EndInit_Mbers block became a private block of the OOP implementation. This private block is used by the new block New : EndNew to perform the instanciation and the initialisation in one way.
So a PureBasic class is at present:

Code: Select all

;Object class 
Class(<ClassName>) 
[Method1()]
[Method2()]
[Method3()]
...
Methods(<ClassName>) 
[<*Method1>]
[<*Method2>]
[<*Method3>]
...
Members(<ClassName>) 
[<Attribute1>]
[<Attribute2>]
...
EndClass(<ClassName>) 

;Object methods (implementation)
Method(<ClassName>, Method1) [,<variable1 [= DefaultValue]>,...])
...
[ProcedureReturn value]
EndMethod(<ClassName>, Method1) 

...(ditto for each method)

;Object constructor
New(<ClassName>)
...
EndNew

;Object destructor
Free(<ClassName>)
...
EndFree
Second, Three new commands:
DeclareMethod, DeclareNew and DeclareFree to be used as the Declare keyword respectively for Methods, Constructors and Destructors. They are not presented in the tutorial
Dräc
Dräc
Enthusiast
Enthusiast
Posts: 150
Joined: Sat Oct 09, 2004 12:10 am
Location: Toulouse (France)
Contact:

Post by Dräc »

Small update: the *this\Instance feacture is full operational

Use it to call methods within the methods!

See http://drac.site.chez-alice.fr/Tutorial ... ur_Alerte1
Dräc
byo
Enthusiast
Enthusiast
Posts: 635
Joined: Mon Apr 02, 2007 1:43 am
Location: Brazil

Post by byo »

I appreciate the effort you put into this. Image
Post Reply