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 / dont understand how functions work.

Author
Message
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 8th Oct 2005 08:34
how do i constantly keep using them?

would i use them for example:1 function would be the ai for several monsters?
Fox Dark Master
20
Years of Service
User Offline
Joined: 20th Jul 2004
Location: Portugal
Posted: 8th Oct 2005 12:19 Edited at: 8th Oct 2005 12:20
Functions are a Procedure that returns a Value. Example:


I think there's no erros cause I really don't have the compiler yet so if someone could test this I'd apreciate that


True Phantasy
smerf
19
Years of Service
User Offline
Joined: 24th Feb 2005
Location: nm usa
Posted: 8th Oct 2005 12:23 Edited at: 8th Oct 2005 12:34
david iz cool instead of making it extreamly difficult or complicated like others would. I'll explain it as simplly as possible.

do you know what a variable is
this A$=blah is a variable it stores information
a function works very simular.

it is a large variable that stors multiple commands that can be called at any time during a program. just buy typing then name just like using a variable.

delcare the function
function whatever you want it to be called()
do what ever here
endfunction

you can either store the function in a different source file if it is very large and just use the include command to use it or if it is in your current source you can just call it buy typing

whaterver you want it to be called()

here is an example
you can use a function for nearly anything

as you can see the entire program can practically be a function. and there is not limit to the size.

just incase you didnt get it a easier way to look at it is like this.

it is the same exact thing except the function allowed you to easily put it into your loop.
since you can minimise and expand a function in dbp editor it makes it very nice to use them since you can shrink an entir portion of your source.

A child's dream never dies.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 8th Oct 2005 13:25 Edited at: 8th Oct 2005 13:26


Think of a function as a recipe or a formula. Its a framework that can accept arguments (ingredients) and it does some work to produce and return a result.

iA as integer = 6
iB as integer = 14
iC as integer

ic=Adder(ia,ib)
`should print 20
print str$(ic)
wait key

Function Adder(a as integer, b as integer)
c as integer
c=a+b
EndFunction c



hope that helps

X_MEN
21
Years of Service
User Offline
Joined: 14th Sep 2003
Location:
Posted: 8th Oct 2005 13:53
hope this help


You can do it if you try
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 8th Oct 2005 14:08
David iz cool
19
Years of Service
User Offline
Joined: 21st Sep 2005
Location: somewhere lol :P
Posted: 8th Oct 2005 15:55

thanks everyone! i think i get it now
TDK
Retired Moderator
22
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Oct 2005 17:25
And don't forget mine (aimed at beginners)!!!

http://www.matedit.com

There are loads of tutorials, hints & tips and stuff for newcomers on my site which answer lots of questions newbies ask over and over again.

Please check it out...

TDK_Man

Login to post a reply

Server time is: 2024-11-27 16:38:00
Your offset time is: 2024-11-27 16:38:00