PureObject - PureBasic OOP support
I went into it and it should work now without bugs when handling multiple Imports also when using IncludePath.SofT MANiAC wrote:ok, lets start...inc. wrote:... you might want to share a part of the code which makes the process crashing.
Thx
Dreamotion site: http://www.dreamotion3d.com/site/downloads.php
http://www.file-upload.net/download-156 ... e.zip.html
Check out OOP support for PB here!
Check out OOP support for PB here!
Check out OOP support for PB here!
Re: PureObject - PureBasic OOP support
Hi,
I apologize if this is a dumb question, I am not an expert coder by any means.
I am still learning, and feeling comfortable with simple concepts, but trying to progress to more complex concepts.
I have been playing with PB OOP and overall it is beginning to make sense.
However, I am having one problem, returning a value from a method
Here is an example I have been trying to write
I am getting the expected values inside the method, but not after the return, I am instead getting strange results outside the method.
Would someone please help me see what I am doing wrong?
I feel as though I almost grasp how to use PB OOP for simple tasks, except this one very confusing bit.
I am baffled.
Thanks,
Dave
I apologize if this is a dumb question, I am not an expert coder by any means.
I am still learning, and feeling comfortable with simple concepts, but trying to progress to more complex concepts.
I have been playing with PB OOP and overall it is beginning to make sense.
However, I am having one problem, returning a value from a method
Here is an example I have been trying to write
Code: Select all
Class vector2D
vector2D()
Release()
set(x.f, y.f, test.s)
getX()
getY()
getTestString()
x.f
y.f
test.s
EndClass
Procedure vector2D\vector2D()
; Constructor
EndProcedure
Procedure vector2D\Release()
; Destructor
EndProcedure
Procedure vector2D\set(x.f, y.f, test.s)
This\x = x
This\y = y
This\test = test
EndProcedure
Procedure.f vector2D\getX()
x.f = This\x
Debug x
ProcedureReturn x
EndProcedure
Procedure.f vector2D\getY()
y.f = This\y
Debug y
ProcedureReturn y
EndProcedure
Procedure.s vector2D\getTestString()
test$ = This\test
Debug test$
ProcedureReturn test$
EndProcedure
*v1.vector2D = NewObject vector2D()
*v1\set(1.0, -1.0, "String Test")
Debug *v1\getX()
Debug *v1\getY()
Debug *v1\getTestString()
Would someone please help me see what I am doing wrong?
I feel as though I almost grasp how to use PB OOP for simple tasks, except this one very confusing bit.
I am baffled.
Thanks,
Dave
Re: PureObject - PureBasic OOP support
@aonyn: Your code needs to be adapted further. One notable item needed for PureBasic OOP is the defining of an interface for an object's methods. Another point is that the constructor sets up access to the interface.aonyn wrote:I am getting the expected values inside the method, but not after the return, I am instead getting strange results outside the method.
Would someone please help me see what I am doing wrong?
I feel as though I almost grasp how to use PB OOP for simple tasks, except this one very confusing bit.
I am baffled.
Here is your code modified to include these points:
Code: Select all
Structure members_Vector2D
;virtual table address for function list
*vtable
;all other object data elements
x.f
y.f
test.s
EndStructure
Interface Vector2D_Object
;list all functions for object
Release()
set(x.f, y.f, test.s)
getX.f()
getY.f()
getTestString.s()
EndInterface
Procedure new_Vector2D()
; Constructor
Protected *object.members_Vector2D = AllocateMemory(SizeOf(members_Vector2D))
If *object
;assign vector table address so object can use the functions in the interface
*object\vtable = ?vector2D_vtable
;assign default values if any
EndIf
ProcedureReturn *object ;return objects address
EndProcedure
Procedure vector2D_Release(*this.members_Vector2D)
; Destructor
FreeMemory(*this)
;the return value is designed to be used like this object = object\Release()
ProcedureReturn #Null
EndProcedure
Procedure vector2D_set(*this.members_Vector2D, x.f, y.f, test.s)
*this\x = x
*this\y = y
*this\test = test
EndProcedure
Procedure.f vector2D_getX(*this.members_Vector2D)
x.f = *this\x
Debug x
ProcedureReturn x
EndProcedure
Procedure.f vector2D_getY(*this.members_Vector2D)
y.f = *this\y
Debug y
ProcedureReturn y
EndProcedure
Procedure.s vector2D_getTestString(*this.members_Vector2D)
test$ = *this\test
Debug test$
ProcedureReturn test$
EndProcedure
DataSection
;vector2D virtual table
vector2D_vtable:
Data.i @vector2D_Release()
Data.i @vector2D_set()
Data.i @vector2D_getX()
Data.i @vector2D_getY()
Data.i @vector2D_getTestString()
EndDataSection
V1.Vector2D_Object = new_Vector2D()
;always make sure return value <> #Null to ensure a valid object was created
If V1 = #Null
Debug "Object couldn't be created"
End
EndIf
V1\set(1.0, -1.0, "String Test")
Debug V1\getX()
Debug V1\getY()
Debug V1\getTestString()
Debug V1 = V1\Release()
Re: PureObject - PureBasic OOP support
Thanks Demivec,
I am going to study your example and try to get my head around it.
It is certainly a good idea for me to understand how purebasic does OOP with native tools only.
May I ask how it would be done correctly as well with the PB OOP precompiler?
I am not sure, bit it seems to be a bit simpler with the precomiler, and I am hoping if I can learn to understand OOP with OOP style tools, it will then perhaps be easier to understand how it works in native PB, which of course is not made for OOP, so the implementation in native PB is perhaps overly complex, and less intuitive to learn.
I will indeed study what you just gave me Demivec, I do want to understand under the hood as well.
I will post back to let you know how I am doing with it.
Thanks again,
and regards,
Dave
I am going to study your example and try to get my head around it.
It is certainly a good idea for me to understand how purebasic does OOP with native tools only.
May I ask how it would be done correctly as well with the PB OOP precompiler?
I am not sure, bit it seems to be a bit simpler with the precomiler, and I am hoping if I can learn to understand OOP with OOP style tools, it will then perhaps be easier to understand how it works in native PB, which of course is not made for OOP, so the implementation in native PB is perhaps overly complex, and less intuitive to learn.
I will indeed study what you just gave me Demivec, I do want to understand under the hood as well.
I will post back to let you know how I am doing with it.
Thanks again,
and regards,
Dave
Re: PureObject - PureBasic OOP support
@aonyn: I'm a little embarrassed. I responded to your question without realizing that the thread dealt with the pre-compiler PureObject. My comments only reflect doing things natively and not with using PureObject, nor any other pre-compiler. My apologies for being a little off-topic with my response.aonyn wrote:I am going to study your example and try to get my head around it.
It is certainly a good idea for me to understand how purebasic does OOP with native tools only.
May I ask how it would be done correctly as well with the PB OOP precompiler?
I am not sure, bit it seems to be a bit simpler with the precomiler, and I am hoping if I can learn to understand OOP with OOP style tools, it will then perhaps be easier to understand how it works in native PB, which of course is not made for OOP, so the implementation in native PB is perhaps overly complex, and less intuitive to learn.
I will indeed study what you just gave me Demivec, I do want to understand under the hood as well.
I will post back to let you know how I am doing with it.
Re: PureObject - PureBasic OOP support
Just a shoot in the dark (didn't tried it), but you will may be have to specify the correct return type in your class defnition ?
Code: Select all
Class vector2D
vector2D()
Release()
set(x.f, y.f, test.s)
getX.f()
getY.f()
getTestString.s()
x.f
y.f
test.s
EndClass
Re: PureObject - PureBasic OOP support
No worries Demivec,
I appreciate your effort to help.
You could have simply ignored my thread.
Besides that, as I said, I want to learn native OOP style as well, but I am trying to understand the basics with a precompiler first, because it seems to simplify things a bit.
Also, thanks for your reply Fred.
That makes sense, and I will give it a try and post back with my results.
regards,
Dave
I appreciate your effort to help.
You could have simply ignored my thread.
Besides that, as I said, I want to learn native OOP style as well, but I am trying to understand the basics with a precompiler first, because it seems to simplify things a bit.
Also, thanks for your reply Fred.
That makes sense, and I will give it a try and post back with my results.
regards,
Dave
Re: PureObject - PureBasic OOP support
Hi Fred,
Thanks again for your advice.
Perhaps it was a shot in the dark for you, but you were absolutely correct.
I typed my method returns in the class definition, and now my code works as expected.
I feel dumb now, it was so obvious now that you have solved it for me
Oh, and off topic, but while I have your attention, thanks for your continued development of PureBasic.
I have been trying to learn to code, in various languages, until about a year ago, when I discovered PureBasic.
I was able to learn very basic concepts, but never to the point of feeling comfortable writing my own apps.
Finally in PureBasic, I am confident and comfortable writing apps which I never dreamed of being capable of previously.
And on top of that, I have yet to experience any limits imposed by lacking features in the language.
No regrets purchasing my license, and I will send a donation soon as thanks for the new version you are working on
regards,
Dave
Thanks again for your advice.
Perhaps it was a shot in the dark for you, but you were absolutely correct.
I typed my method returns in the class definition, and now my code works as expected.
I feel dumb now, it was so obvious now that you have solved it for me
Oh, and off topic, but while I have your attention, thanks for your continued development of PureBasic.
I have been trying to learn to code, in various languages, until about a year ago, when I discovered PureBasic.
I was able to learn very basic concepts, but never to the point of feeling comfortable writing my own apps.
Finally in PureBasic, I am confident and comfortable writing apps which I never dreamed of being capable of previously.
And on top of that, I have yet to experience any limits imposed by lacking features in the language.
No regrets purchasing my license, and I will send a donation soon as thanks for the new version you are working on
regards,
Dave
Re: PureObject - PureBasic OOP support
@ inc.
Did you know your OOP forum page still shows this:
"This free forum hosting network is under New Management.
We are reviewing all our phpBB version 2 free forum for possible violation.
If you are still viewing this page, please contact us at immediately to get your forum Reviewed and Activated within minutes.
MSN Messenger: freeforum@noeclue.com
Email Support: freeforum@noeclue.com
Any members of this forum can request to get this forum reviewed and activated. When you send either a messenger or email, Please include your full forum URL!
In the meantime, feel free to browse our company online shopping.
Note: New Support Forum will be up and running by tomorrow night!"
?
Did you know your OOP forum page still shows this:
"This free forum hosting network is under New Management.
We are reviewing all our phpBB version 2 free forum for possible violation.
If you are still viewing this page, please contact us at immediately to get your forum Reviewed and Activated within minutes.
MSN Messenger: freeforum@noeclue.com
Email Support: freeforum@noeclue.com
Any members of this forum can request to get this forum reviewed and activated. When you send either a messenger or email, Please include your full forum URL!
In the meantime, feel free to browse our company online shopping.
Note: New Support Forum will be up and running by tomorrow night!"
?
Last edited by SFSxOI on Sun Jan 03, 2010 2:18 am, edited 1 time in total.
The advantage of a 64 bit operating system over a 32 bit operating system comes down to only being twice the headache.
Re: PureObject - PureBasic OOP support
yeah, i did notice that and I did send a mail but with NO answer or even reopening the specific forum.
I you do know a good free forum space? Seems like http://www.forumer.com/ is worth a look.
But with all honours ... seems almost noone was interested in a specific community dealing with PureObject means PB OOP capabilities.
In times of beeing online, at the end that forum only gots about 15 registrations, so .... I think those topics could be handled in here as well.
But of cource my sig now is updated
I you do know a good free forum space? Seems like http://www.forumer.com/ is worth a look.
But with all honours ... seems almost noone was interested in a specific community dealing with PureObject means PB OOP capabilities.
In times of beeing online, at the end that forum only gots about 15 registrations, so .... I think those topics could be handled in here as well.
But of cource my sig now is updated
Check out OOP support for PB here!
Re: PureObject - PureBasic OOP support
Hello,
It seems there is a problem with accented characters when using PureObject. For example:
When PureObject is installed in PB's default ide, the preprocessed source's encoding is wrong, which affects accented chars (i.e. when passing them to a function, setting a variable, etc).
With the commandLine compiler (and without PureObject in the IDE) everything works fine.
I thought I'd post it here at first, but please let me know if filling a bug report on your site would be better.
Erion
It seems there is a problem with accented characters when using PureObject. For example:
Code: Select all
MessageRequester("","óűáőúéí")
With the commandLine compiler (and without PureObject in the IDE) everything works fine.
I thought I'd post it here at first, but please let me know if filling a bug report on your site would be better.
Erion
To see a world in a grain of sand,
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.
- W. B.
Visit my site, also for PureBasic goodies http://erion.tdrealms.com
And a heaven in a wild flower,
Hold infinity in the palm of your hand,
And eternity in an hour.
- W. B.
Visit my site, also for PureBasic goodies http://erion.tdrealms.com