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 / Functions question

Author
Message
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 14th Feb 2005 19:08
I've got a question about Functions.
I've used them alot, but atm i'm working on a project that requires some function to return a values.

It says in the helpfile, and i quote: "...they can accept return values..."

My questions is now.. how do i get a function to return a value? And how does it work?

Rye
21
Years of Service
User Offline
Joined: 30th May 2003
Location: United Kingdom, Blackrod
Posted: 14th Feb 2005 19:25
function blah(val1)

do stuff with val1
make a value and store in variableName

endfuction variableName

then to use this function call it like this

x = blah(32)

then the return value from the function will be stored in x
Monzi
20
Years of Service
User Offline
Joined: 10th May 2004
Location: Denmark
Posted: 15th Feb 2005 01:09
sorry to be stupid... but i dont understand the (32)??

Rye
21
Years of Service
User Offline
Joined: 30th May 2003
Location: United Kingdom, Blackrod
Posted: 15th Feb 2005 01:33
the blah(32) is just a way of putting a value into the function.

in this example you would use 2 numbers when calling the function

the function will then do some simple maths to them.


function maths(num1, num2)

result = num1*num2

endfunction result


when calling this function you MUST put 2 values into it.
just like when calling one of the DB commands such as Object Posistion x(). for that one you MUST specify which object you want the x position for. eg Object Position x(100)

when calling a function that returns a result you need somewhere to put the result. we do this by making a variable equal to the function.

x = maths(10,2)

from the maths function the result would be 20. this result would be placed into the variable x.
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 15th Feb 2005 07:27
good explanation Rye

Login to post a reply

Server time is: 2024-11-11 23:46:16
Your offset time is: 2024-11-11 23:46:16