Procedure in a Structure in PureBasic ?

Just starting out? Need help? Post your questions and find answers here.
newcoder
User
User
Posts: 13
Joined: Tue Nov 25, 2003 11:34 pm

Procedure in a Structure in PureBasic ?

Post 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 :

Code: Select all

SmallStruct\SayHello("Hello")
Thanks in Advance
Karbon
PureBasic Expert
PureBasic Expert
Posts: 2010
Joined: Mon Jun 02, 2003 1:42 am
Location: Ashland, KY
Contact:

Post 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.
-Mitchell
Check out kBilling for all your billing software needs!
http://www.k-billing.com
Code Signing / Authenticode Certificates (Get rid of those Unknown Publisher warnings!)
http://codesigning.ksoftware.net
newcoder
User
User
Posts: 13
Joined: Tue Nov 25, 2003 11:34 pm

Post 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()
Shannara
Addict
Addict
Posts: 1808
Joined: Thu Oct 30, 2003 11:19 pm
Location: Emerald Cove, Unformed

Post 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?
Codemonger
Enthusiast
Enthusiast
Posts: 384
Joined: Sat May 24, 2003 8:02 pm
Location: Canada
Contact:

Post by Codemonger »

Yes their is

Search for the Clock example ... on the forum. It creates a class.
<br>"I deliver Justice, not Mercy"

    - Codemonger, 2004 A.D.
User avatar
tinman
PureBasic Expert
PureBasic Expert
Posts: 1102
Joined: Sat Apr 26, 2003 4:56 pm
Location: Level 5 of Robot Hell
Contact:

Post 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)
If you paint your butt blue and glue the hole shut you just themed your ass but lost the functionality.
(WinXPhSP3 PB5.20b14)
User avatar
GedB
Addict
Addict
Posts: 1313
Joined: Fri May 16, 2003 3:47 pm
Location: England
Contact:

Post 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.
Post Reply