Page 1 of 1
Procedure in a Structure in PureBasic ?
Posted: Thu Nov 27, 2003 6:44 pm
by newcoder
I'm very sorry if this question has been answered many times , but is it possible have and Procedure inside a structure
Example :
Thanks in Advance
Posted: Thu Nov 27, 2003 6:58 pm
by Karbon
No, I don't think that's possible. Search the forum for OOP to get some ideas on how to do object oriented things in PB.
Posted: Thu Nov 27, 2003 7:22 pm
by newcoder
Thanks Karbon,
After doing a search on the forums I found that a BIG discussion had taken place about OOP back in June.
The reason for this question is because I am currently trying to design and develop a small 2d game engine to help me to prevent writing the same non-specific game code over and over again.
I thought that maybe having my procedure attached to my structure would make my engine seem a little bit more organized.
Such as :
Code: Select all
2DEngine\Intit2DFunctions()
2DEngine\DrawAllSprites()
Posted: Thu Nov 27, 2003 8:36 pm
by Shannara
Yeah, even having classes in structures would be quite helpfull. But there will be no OOP in this version of the basic dialect, is there?
Posted: Thu Nov 27, 2003 9:34 pm
by Codemonger
Yes their is
Search for the Clock example ... on the forum. It creates a class.
Posted: Fri Nov 28, 2003 11:51 am
by tinman
As you will have seen in that big discussion, something like this should work, even though it's a bit more awkward.
Code: Select all
Structure foo
my_proc.l
EndStructure
Procedure bleh()
Debug "hell, world"
EndProcedure
DefType.foo bar
bar\my_proc = @bleh()
CallFunctionFast(bar\my_proc)
Posted: Fri Nov 28, 2003 5:06 pm
by GedB
Newcoder,
The interface function introduced in version 3.8 does the job for you.
Interfaces are used by Microsoft's COM standard for creating Components that can be accessed by any language.
With version 3.8 we can do the same in Purebasic, though it is still early days.
It's still awkward, and I haven't got a good example yet.
Take a look at this post for my work in progress:
viewtopic.php?p=40599#40599
I hope to have a tutorial prepared soon.