Page 2 of 4
Posted: Sun Jan 27, 2008 5:25 pm
by blueznl
Superadnim, cool off, step back. That's trolling and you know it. Comments like those only make me react in one way:
YOU write something better, and THEN you're allowed those kind of comments.
(Show us something you wrote, then WE can laugh.)
Posted: Mon Jan 28, 2008 12:48 am
by oldBear
If I remember correctly, Superadnim has been warned at least once before about this kind of behavior.
Shame some people just don't learn.
Posted: Sun Feb 24, 2008 8:06 pm
by the.weavster
mk-soft you rock.
superadnim - is he really super?
Write your answers on the back of a five pound note and send them to:
the.weavster
...
Posted: Thu Feb 28, 2008 9:19 pm
by mk-soft
Hi,
For which you use my Precompiler and run it?
Need still for the advancement still two stable functions with rollback.
Code: Select all
Procedure RegDLL(ProgID.s, CLSID.UIID, InprocServer32.s = "Apartment")
EndProcedure
Procedure UnregDLL(CLSID.UIID)
EndProcedure
who can help me?
Thanks
P.S. Helpertools for UUID as DataSection is Ready.
Download UuidGenerate
Posted: Thu Apr 24, 2008 3:51 pm
by mk-soft
Simply OOP Dialog example. Using Threadsave.
Code: Select all
Class DlgWindow Extends BaseClass
; Attributes
WinID.l
hThread.l
Exit.l
Caption.s
EndClass
; Method DlgWindow_Function(*this.DlgWindow)
;
; With *this
;
; EndWith
;
; EndMethod
Method DlgWindow_Create(*this.DlgWindow)
With *this
\WinID = OpenWindow(#PB_Any, #PB_Ignore, #PB_Ignore, 300, 200, \Caption)
EndWith
EndMethod
Method DlgWindow_Event(*this.DlgWindow)
Protected event.l
With *this
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_CloseWindow
\Exit = #True
EndSelect
Until \Exit
Debug "Exit Thread ID " + Str(\hThread)
CloseWindow(\WinID)
EndWith
EndMethod
Method DlgWindow_IsExit(*this.DlgWindow)
ProcedureReturn *this\Exit
EndMethod
; Private
Procedure DlgInit(*this.IDlgWindow)
*this\Create()
*this\Event()
EndProcedure
Method DlgWindow_Run(*this.DlgWindow, Caption.s)
With *this
\Caption = Caption
\hThread = CreateThread(@DlgInit(), *this)
EndWith
EndMethod
; Test
Define.IDlgWindow *dlg1, *dlg2
*dlg1 = NewObject(DlgWindow)
*dlg2 = NewObject(DlgWindow)
*dlg1\Run("Diaglog 1")
*dlg2\Run("Diaglog 2")
Debug "Start.."
Repeat: Delay(100) : Until *dlg1\IsExit() And *dlg2\IsExit()
*dlg1\Release()
*dlg2\Release()
Debug "Ready."
GT
Posted: Thu Apr 24, 2008 11:27 pm
by neotoma
very impressive.
i tried with that, and i'm missing a 'Super'-Var/pointer to call a method on the class from we inherited.
(Maybe as a pointer).
With that we can use also the functionality from the 'Parent'-Object.
Say - if we write a Baseclass that has the functionality to serialize itself (only the important vars). If we derive from that we also 'overwrite' the serialize-function. but instead to serialize all the vars, we only call the 'Parent' (in java as Super())-Function (it serialze the vars of the parent object, and now we only have to serialize the vars we need for my class (members).
Mike
Posted: Fri Apr 25, 2008 12:23 am
by mk-soft
Sorry, i don´t understand complete what you mean. (my english)
but when you need a method from myclass, only define the method from myclass.
Code: Select all
Class MyClass Extends BaseClass
; Attributes
EndClass
Method MyClass_Function1(*this.MyClass)
With *this
Debug "Test 1"
EndWith
EndMethod
Method MyClass_Function2(*this.MyClass)
Protected *self.iMyclass = *this
With *this
*self\function1()
EndWith
EndMethod
*obj.imyclass = NewObject(myclass)
*obj\function2()
This is all for self and inherited method, not parend class object because is not exists.
P.S. I added an optional parameter by NewObject(Class, ParendClass) at time.
Posted: Fri Apr 25, 2008 1:18 pm
by neotoma
mk-soft wrote:Sorry, i don´t understand complete what you mean. (my english)
Same for my english... if germans write english...
But i think it is also interesting for the people here around. So i try to explain this a little bit more (next try..)
Say i have a Baseclass like :
Code: Select all
Class cBase
cBase()
serialize(*xml_node)
deserialize(*xml_node)
id.l
name.s
type.l
EndClass
Procedure cBase.cBase()
EndProcedure
Procedure cBase.serialize(*xml_node)
;
;.. write id, name and type as tags to the xml.
;
EndProcedure
Procedure cBase.deserialize(*xml_node)
;
;.. read id, name and type as tags from the xml.
;
EndProcedure
Now i want hav a class the derives from the base class :
Code: Select all
Class cAction
cAction()
execute()
serialize(*xml_node)
deserialize(*xml_node)
;now only the vars for this Action
;we iherited the id,name and type from the base-class
actionName.s
actionPath.s
actionTimeout.l
EndClass
Procedure cAction.cAction()
;; should able to call the parent Constructor
;; for basic initis.
;;but without knowing the name of the Base-Class
EndProcedure
Procedure cAction.execute()
;;Do the Action
EndProcedure
Procedure cAction.serialize(*xml_node)
;;call parent first
*parent\serialize(*xml_node)
;;
;; now write my own vars to the xml
EndProcedure
Procedure cAction.deserialize(*xml_node)
;;call parent first
*parent\deserialize(*xml_node)
;;
;; now read my own vars from the xml
EndProcedure
This ends up with the 'feature' that i can have a Array or LinkedList filled with different action-objects, but i have only to call 'execute() to start the action, and using a serialize() to write them (completly) or a deserialize() to read them back.
I have not to know the parent of a class. That should be capsuled via OO.
I hope that clears what i want . So i was a C++/Java man, and i wrote the Pattern (Command-Pattern) often enough. And i really like it much.
Would be nice - and important - to get that work.
BTW: I cannot understand Fred with his ignorance against OOP. He gives us the Interface as a basic step to OOP but denies support via Compiler.
So he has not to reinvent the complete Purebasic only to add a feature. that the people can use - if the want. Maybe as for some extra cash.
(i would pay for that !)
But its a fact that OO is a good solution for greater projects.
Mike
EndClass
Posted: Fri Apr 25, 2008 7:18 pm
by mk-soft
Update v0.35 (Only Windows, Linux at time)
NewObject calling the Method "InitObject()". Now can overwrite this method for initialzed the object.
example:
Code: Select all
; Example Part 3 - avoidance of memory leak with self method Release
Class MemClass Extends BaseClass
*mem1
*mem2
EndClass
; Init memory
Method Overwrite MemClass_InitObject(*this.MemClass) ; <- NewObject call InitObject
With *this
Debug "InitObject: AllocateMemory."
\mem1 = AllocateMemory(10*1024)
\mem2 = AllocateMemory(20*1024)
EndWith
EndMethod
Method MemClass_GetMemPointer(*this.MemClass, number.l)
Select number
Case 1 : ProcedureReturn *this\mem1
Case 2 : ProcedureReturn *this\mem2
Default : ProcedureReturn 0
EndSelect
EndMethod
Method Overwrite MemClass_Release(*this.MemClass)
; Decrease internal refcounter
If *this\__Ref > 1
*this\__Ref - 1
ProcedureReturn *this\__Ref
Else
Debug "Release: Free Memory."
FreeMemory(*this\mem1)
FreeMemory(*this\mem2)
; Release Object
ProcedureReturn DeleteObject(*this)
EndIf
EndMethod
; Test Part 3
Debug "Test Part 3"
Debug ""
Debug "Mem Test 1"
*mem.IMemClass = NewObject(MemClass)
Debug "Address of mem1: " + Str(*mem\GetMemPointer(1))
Debug "Address of mem2: " + Str(*mem\GetMemPointer(2))
*mem\Release()
Debug ""
Debug "Mem Test 2"
*mem.IMemClass = NewObject(MemClass)
Debug "Address of mem1: " + Str(*mem\GetMemPointer(1))
Debug "Address of mem2: " + Str(*mem\GetMemPointer(2))
*mem\Release()
Debug ""
GT
Posted: Sat Apr 26, 2008 2:40 am
by mk-soft
Update v0.36
Bugfix: InitObject()
------------------------------
Edit
Super var-pointer does not correspond the COM objects to specification. There tries to remain compatible for later DLL´s for these will not integrate itself. Who white still another solution those the integrity does not injure.
Sorry,
------------------------------
I have still no solution for parent method.
Code: Select all
Class cBase Extends BaseClass
; Method
; cBase()
;serialize(*xml_node)
;deserialize(*xml_node)
; Attribues
id.l
name.s
type.l
EndClass
Method cBase_InitObject(*this.cBase)
EndMethod
Method cBase_serialize(*this.cBase, *xml_node)
;
*this\name = "cBase Serialize"
;
EndMethod
Method cBase_deserialize(*this.cBase, *xml_node)
;
;.. read id, name and type as tags from the xml.
*this\name = "cBase deserialize"
;
EndMethod
Class cAction Extends cBase
; inherited methods
;serialize(*xml_node)
;deserialize(*xml_node)
; Methods
;cAction()
;execute()
;now only the vars for this Action
;we iherited the id,name and type from the base-class
actionName.s
actionPath.s
actionTimeout.l
EndClass
Method Overwrite cAction_InitObject(*this.cAction)
;; should able to call the parent Constructor
;; for basic initis.
;;but without knowing the name of the Base-Class
EndMethod
Method cAction_execute()
;;Do the Action
EndMethod
Method Overwrite cAction_serialize(*this.cAction, *xml_node)
;;call parent first
cbase_serialize(*this, *xml_node) ; <- Call old method: I have still no solution
Debug *this\name
;;
;; now write my own vars to the xml
EndMethod
Method Overwrite cAction_deserialize(*this.cAction, *xml_node)
;;call parent first
cbase_deserialize(*this, *xml_node)
Debug *this\name
;;
;; now read my own vars from the xml
EndMethod
*obj.icAction = NewObject(cAction)
*obj\serialize(100)
*obj\deserialize(100)
[/b]
Posted: Thu May 01, 2008 1:38 pm
by mk-soft
Update v0.36
Linux version now available
GT
P.S. OOP-Dialog under a linux not running
Posted: Sat May 03, 2008 4:11 pm
by mk-soft
Update v0.37
Structure BaseClass have now a pointer to parent object
Chaos example:
Code: Select all
; Example for parent object
; Structure BaseClass have now a pointer to parent object
Class Sub Extends BaseClass
text.s
EndClass
Class Master Extends BaseClass
; Attribute
text.s
sub.ISub[20]
EndClass
; Sub Class Methods
; Method Sub_Function(*this.Sub)
; With *this
;
; EndWith
; EndMethod
Method Sub_InitObject(*this.Sub)
With *this
Debug "Parent Pointer: " + Str(\parent)
EndWith
EndMethod
Method Sub_Test(*this.Sub)
Protected *parent_data.master = *this\parent ; Set pointer to parent data
Protected *parent_method.imaster = *this\parent ; Set pointer to parent interface
With *this
\text = "SubText = Parent Text -> " + *parent_data\text
Debug \text
Debug "Parent Method GetText() = " + *parent_method\GetText()
EndWith
EndMethod
; Master Class Methods
; Method Master_Function(*this.Master)
; With *this
;
; EndWith
; EndMethod
; Method Init Object
Method Master_InitObject(*this.Master)
With *this
\text = "Hello Master Text"
EndWith
EndMethod
Method.s Master_GetText(*this.Master)
With *this
ProcedureReturn \text
EndWith
EndMethod
Method Master_NewSub(*this.Master, ID)
With *this
\sub[ID] = NewObject(sub)
ProcedureReturn \sub[id]
EndWith
EndMethod
*master.imaster = NewObject(master)
Debug *master\gettext()
*sub1.isub = *master\NewSub(0)
*sub1\test()
Who writes a better example
Posted: Sat May 03, 2008 8:11 pm
by SofT MANiAC
really good work!
Posted: Sat May 03, 2008 8:34 pm
by SofT MANiAC
superadnim wrote:I guess I'll have to continue mine after all...
Chatter and chatter
Posted: Wed May 07, 2008 8:27 pm
by SofT MANiAC
Fatal error!
Code: Select all
XIncludeFile #PB_Compiler_Home + "somefile.pbi"
Class MyClass Extends BaseClass
EndClass
-
not works (Syntax error, topfile.oop
not created)!
Code: Select all
XIncludeFile "d:\PB4\somefile.pbi"
Class MyClass Extends BaseClass
EndClass
- works (not always - e.g. I can't include DX9-includes by Steven (Dreglor) Garcia)!
Fix please?
@inc
You have this problem too (remind my issue?)