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.

Newcomers DBPro Corner / Making New Commands in DBP with functions

Author
Message
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Aug 2007 04:42
Hello, I am going to teach you how to make new commands out of DBP using functions! That's right, not DLL's, but FUNCTIONS!

Our function will be a thing called MakeWood(). The command will be layed out like this.

MakeWood (#,xpos#,ypos#)

Now don't get all excited and think we can also make an INI file for it. Because no we can't.

First type this in,



K? Now we make what our command will do, e.g.



There you go! No you can try it!

The IMAGE FILE is below

Attachments

Login to view attachments
The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 3rd Aug 2007 05:06 Edited at: 3rd Aug 2007 05:13
This is no offence or anything. It's nice that you wanna give something to the community. The only problem is that I wouldn't really call this a tutorial. I mean, you don't really give much information about functions at all, other than you can use them to simplify a piece of code. There's more to it. Like in what way they are put in good use, pro's and con's, and what about variables you declare inside them? Reasons to use functions, and so on. There's much more to it. This is really just very basic information that you could have found by searching the forum

And you can make an ini file for your functions... if you mean like for syntax highlightning. If you use DBPro atleast.

again, this isn't ment as an offence, just some advice and thoughts, hehe.

Here's a tutorial on functions(yep, there's already one out there):
http://forum.thegamecreators.com/?m=forum_view&t=87472&b=7

Gives you an idea of just how much more there is to tell.

Cheers.

Lucifer
18
Years of Service
User Offline
Joined: 26th Dec 2005
Location:
Posted: 3rd Aug 2007 05:09 Edited at: 3rd Aug 2007 05:15
cool tutorial jsg, but when you make functions you're not making your own commands, you're making your own functions, it's quite different isnt it? but this might come in handy for people trying to learn how to make functions but there are already tutorials that go much deeper into explaining how functions work so this wont help much for beginners (sorry) you should put more into your next tutorial ...

but isnt it a more proper way to do it like this? (havent tested but should work fine)


i understand you are just trying to help and i have nothing but respect for that but you know.. try to put more into it...


oh praise the lord, praise furry jesus
Zeus
18
Years of Service
User Offline
Joined: 8th Jul 2006
Location: Atop Mount Olympus
Posted: 3rd Aug 2007 05:22
okay thanks.

TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 3rd Aug 2007 07:04
Quote: "function MakeWood(#,x#,y#)"


I don't see how that would even run!

How can you have a hash symbol (#) on it's own as a parameter when it's an identifier for a variable?

Has DBP changed that much from DBC?

TDK_Man

Kieran
18
Years of Service
User Offline
Joined: 6th Aug 2006
Location: Hamilton, New Zealand
Posted: 3rd Aug 2007 08:55
Quote: "Now don't get all excited and think we can also make an INI file for it. Because no we can't."


actually yes we can.

Nice of you to give to the community but I don't think you are quite ready to write tutorials. You must go more in-depth as well and make sure you show more than just a command that already exists.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Aug 2007 11:24
I've removed the work "tutorial" from the subject, as it's somewhat misleading for people new to the forums.

The Nerd
20
Years of Service
User Offline
Joined: 5th Jun 2004
Location: Denmark
Posted: 3rd Aug 2007 15:56
Quote: "How can you have a hash symbol (#) on it's own as a parameter when it's an identifier for a variable?

Has DBP changed that much from DBC?
"


While it isn't very smart to do, it is actually possible. This compiles for me:


BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Aug 2007 17:59
It may work, but it's bad practise.
One of the reasons why "tutorials" get scrutinised is because they are aimed at newcomers and should be as clear as possible, and use only best-practise. Coders pick up enough bad habits of their own without being taught them

PowerSoft
20
Years of Service
User Offline
Joined: 10th Oct 2004
Location: United Kingdom
Posted: 3rd Aug 2007 18:47
Quote: "function MakeWood(#,x#,y#)"


Woah! thats some crazy stuff going on there...

The Innuendo's, 4 Piece Indie Rock Band
http://theinnuendos.tk:::http://myspace.com/theinnuendosrock
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 4th Aug 2007 06:10
Quote: "It's just that the compiler sets the default type of a variable based on the last character of its name."


To me, that's a good description of an identifier and for the # to be the last character, there should be one of more characters preceding it.

But, although it is accepted by DBP - which surprised me, as Batvink says it's bad practice and not a good idea to use it in this way.

I wouldn't say that the hash symbol is a character just like any other either - for the same reason that the $, * or : isn't. As DB specifies that they are all used by DB for a specific purpose, they could be classed as 'reserved words'.

But I agree that your examples do work as you say in DB - even though they shouldn't!

TDK_Man

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 4th Aug 2007 14:20
My long answer was eaten by the chronic Virgin broadband service that conks out every 2 minutes right now (not an exagerration, it dies every 2 minutes).

So here is the short answer...

You should never use symbols in variable names. Not for the sake of the compiler. Not for the sake of the programmer. But for the sake of regional differences.

Different codepages transpose certain characters, especially hash, pound and dollar. You can't guarantee a pound symbol on your PC won't be something else in Denmark or Manilla or Iceland. And if it transposes to something that the compiler has an issue with, then you could have a lot of rewrites to make.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 5th Aug 2007 01:10
You missed the point. Using symbols as variables is bad coding practise. The language is irrelevant.

I have seen competent coders develop bad habits in one language and get away with it because the compiler is kind to them, only to move to another language and look like complete buffoons when it all goes pear shaped.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Aug 2007 00:45
I made my point. I won't be returning to this thread.

Login to post a reply

Server time is: 2024-11-25 13:27:04
Your offset time is: 2024-11-25 13:27:04