Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / can you make records or classes in DBPro?

Author
Message
kfoong
23
Years of Service
User Offline
Joined: 28th Jan 2003
Location: Australia
Posted: 3rd May 2003 05:53
Some programs uses records or classes depending on the language. C++ uses classes and pascal uses records. They're exactly the same thing. here is a little example.

classname.classvariable = 5

does that ring a bell? If can you do it with DBPro?
Quote from my brother:
Quote: " Patience is a virtue... I know that but how does that help me? "

http://www.stellarblue.vze.com/
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd May 2003 06:24
try types

eg:
Monster(1).NAME
Monster(1).HPS

Vandetta
23
Years of Service
User Offline
Joined: 17th Dec 2002
Location:
Posted: 3rd May 2003 06:36
only problem is you cant have functions inside of types like you can with classes, but whatcha gonna do

indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd May 2003 06:52
a typed array command works as a parameter inside a function call.



watcha gonna do is try before u spew incorrect info

kfoong
23
Years of Service
User Offline
Joined: 28th Jan 2003
Location: Australia
Posted: 3rd May 2003 08:16
i dont understand please explain.

Quote from my brother:
Quote: " Patience is a virtue... I know that but how does that help me? "

http://www.stellarblue.vze.com/
indi
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: Earth, Brisbane, Australia
Posted: 3rd May 2003 10:42
Gardocki
23
Years of Service
User Offline
Joined: 31st Oct 2002
Location:
Posted: 4th May 2003 02:53
You can create types (same as structures in C++) in DarkBasic, but as far as I know, Classes as such cannot be made. In classes, a Class identifier holds 2 things: structs/types and functions. DB/DBPro cannot create this type of code. However, functions can contain types, which is kinda like classes in reverse.

MrTAToad
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: United Kingdom
Posted: 4th May 2003 03:11
For classes, you would need an OOP language. DBPro is not OOP.

Good news everyone! I really am THAT good...
http://www.nickk.nildram.co.uk/ for great plug-ins - oh my, yes!
Fluffy Paul
23
Years of Service
User Offline
Joined: 16th Dec 2002
Location: United Kingdom
Posted: 8th May 2003 19:46
I simulated OO classes in my final year project (written in DBPro)!
I had a template for each new "class" that I needed:


Note that originally the kill function was going to delete array elements if they were at the end of the Mdata(0) array. That command doesn't work at the minute! Instead I just set the attributes to blank or zero values.
Also note that my classes would have some sort of attribute (other than the three specified) that would indicate if it was in use. When recycling an old, blank object the line which reads "if M_get(n)=0" would have the name of the function I need to check if an object is in use. If the attribute was the id of the object then that line would read "if M_getId(n)=0".
I would add attributes to the type definition as needed. For example I use this system to manage my entities in-game. I could add an attribute to store the health of the entity. In this case I'd need some "get" and "set" functions for that, too.
Remember, that's a template with blanks that need to be filled. That's why the generic get and set functions don't assign anything to the value variable - until I use the blank function for something I don't know if it's going to be a string, a float or what.
I've used this approach in my project for loads of different things, even managing objects and images! Let me know if this is helpful!

Ending a sentence with a French word is so passé

Login to post a reply

Server time is: 2026-07-11 08:47:02
Your offset time is: 2026-07-11 08:47:02