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.

Dark GDK / Question about functions in DarkGDK

Author
Message
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 3rd Jan 2013 00:30
Ok, I have not found a lot of learning material on DarkGDK, I have learned SOME c++ and SOME DBP. I have the book Hands on DBP v 1 and 2. I don't really follow the book page by page I read and try things that really interest me and figure when I need to know some of the more un-interesting stuff I will know it then read up on it and try it.

I have also figured I want to do things in c++ so I have been reading the book, doing the exercises in DBP then doing them in DarkGDK so I am learning both at the same time.

it seems to me every command in DarkGDK is like dbCommandName(). I am not sure if that makes everything a function but I kind of think so so someone correct me if I am wrong!

My question is how do I make my own function? do I do it like this?

function functionName() or do I have to put db in front of it like this
function dbFunctionName()

I am not exactly sure how to set up my own functions and declare them in DarkGDK

Thanks
Dragonslayer
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 3rd Jan 2013 03:11
Can someone help me out on this or point to some Tuts? I have done the tuts from DarkGDK then ported them to DBP and ran them there to see if they ran any slower. Noticed no difference,
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 3rd Jan 2013 03:24 Edited at: 3rd Jan 2013 03:27
DarkGDK is just big set of functions, you declare them in C++, which is entirely different and a bit harder than dbPro, but much more powerful and flexible. To make your own function you must:

1.) Declare what datatype your functions will return
2.) Name the function
3.) Declare inputs (optional)

Functions can be named anything you wish, for example:

void MyFunction()
{
INSERT YOUR CODE HERE
}

"void" is a keyword that tells your C++ compiler that the function will not return any data.

Just put what you want the function to do in the braces. I reccomend you follow through the tutorial series on this site: http://www.cplusplus.com/doc/tutorial/functions/

That one covers functions, but it can teach you the whole language. If you stick with C++, even through the "tough times" it can have, you will know a very powerful and robust multi-purpose programming language.
Dragon slayer
18
Years of Service
User Offline
Joined: 3rd Nov 2006
Location: Bourbonnais Illinois
Posted: 5th Jan 2013 16:53
Ok thanks I understand functions I do understand that GarkGDK is mostly all functions, I just was not sure how to declare my own in DarkGDK I was not sure if I had to do anything but from what you say it is just the same as in regular c++!
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 8th Jan 2013 03:40
Quote: " I was not sure if I had to do anything but from what you say it is just the same as in regular c++!"


Exactly.
JohnFT
13
Years of Service
User Offline
Joined: 6th Apr 2011
Location:
Posted: 11th Feb 2013 03:19
I'm using DBpro/PureBasic/DarkNet/Styx... I'm programming in C++, how do I print integer results to a DB window? I see dbText for Strings, but nothing for anything else... Thanks
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 11th Feb 2013 07:13
Use dbStr(float Value) to convert the float/integer to a string like this: dbText(0, 0, dbStr(100));
JohnFT
13
Years of Service
User Offline
Joined: 6th Apr 2011
Location:
Posted: 12th Feb 2013 03:02
That works sometimes, but not when programming in CPP and using DarkGGK/DarkBasic/DarkNet... Perhaps I'm missing something, but I only see dbText(x,y,string). Have you tried it? Please let me know if it works on your system... Thanks
JohnFT
13
Years of Service
User Offline
Joined: 6th Apr 2011
Location:
Posted: 12th Feb 2013 06:39
I'm using the gdkengine.dll, which combined the DB Core/plugins/plugins-licensed... into one compressed dll... don't know why it doesn't include the dbStr command. I guess I could also configure it differently, and then dbStr would work. Right now though, I just added CPP code to convert the int to string first.
Rudolpho
18
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 15th Feb 2013 22:13 Edited at: 15th Feb 2013 22:14
Quote: "don't know why it doesn't include the dbStr command"

According to the documentation certain such functions have been omitted to force the user to use the system's own representation and functionality for manipulating things such as strings. In C++ and concerning strings that is easiest done by using the std::string datatype ( #include <string> ) and a stringstream ( #include <sstream> ) for converting other datatypes to strings.


"Why do programmers get Halloween and Christmas mixed up?"

Login to post a reply

Server time is: 2024-11-18 21:51:59
Your offset time is: 2024-11-18 21:51:59