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 / return value?

Author
Message
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 16th Feb 2004 07:14
I was just reading up on some tutorials for Functions and at the endfunction and exitfunction it says syntax is like :
endfunction [return value]
exitfunction [return value]

What is a return value and how is it used/ where is it returned?¿
Also does anyone know of a tutorial that covers all aspects of functions?
BearCDPOLD
20
Years of Service
User Offline
Joined: 16th Oct 2003
Location: AZ,USA
Posted: 16th Feb 2004 08:08
The return value is easy to understand, but confusing to explain.

Take a command like

OBJECT POSITION Z(obj)

We know that this is not the correct syntax, you must say that something is equal to OBJECT POSITION Z(obj)

CoolObjectZPos=OBJECT POSITION Z(obj)

Whatever value is stored into CoolObjectZPos is the return value. Here is an example of a function.

FUNCTION One_Plus_One()
answer=1+1
ENDFUNCTION answer

If we typed:

AdditionAnswer=One_Plus_One()
PRINT AdditionAnswer

The text "2" would appear on screen. Exitfunction works the same way, except it allows you to break out of a function early and include a return value. There are just a few rules of functions.

1. Anything that is not a GLOBAL variable or Array must be passed to the function.
2. Variables created within the function are deleted after the function is finished running.
3.The syntax:
FUNCTION Function_Name(any parameters to pass in here)
`commands
ENDFUNCTION ReturnAValueIfYouWant
4. All parameters you pass to the function must be the same as the ones you defined in the function declaration.

If you create

FUNCTION MyFunc(integer, string$, integer)
`stuf
ENDFUNCTION

Then you must always call it with
MyFunc(An_Integer, A_String$, Another_Integer)

You don't need those names, just the types need to be the same.

I doubt all of this is comprehendable, if you need clarification on any of it, just type a reply.

Crazy Donuts

Crazy Donut Productions
Current Project: KillZone
Lost in Thought
20
Years of Service
User Offline
Joined: 4th Feb 2004
Location: U.S.A. : Douglas, Georgia
Posted: 16th Feb 2004 10:06
Thank You! Thats exactly what i've been looking for

Login to post a reply

Server time is: 2024-09-21 21:01:37
Your offset time is: 2024-09-21 21:01:37