Return

Blitz3D Forums/Blitz3D Programming/Return

What is the point of and when would you need to use the return command?

Please don't just tell me to look in the manual, it didn't help me at all.

thnx!

Use the return command if you need to return a variable/type that the calling code would need. For example, if you wrote a function that calculates the height of a mesh at a certain coordinate, you would expect to be able to get that value back to wherever you needed it. This is the function of return.

Ohhhh...Thanks so much, i've been trying to figure that out for so long!

One point to bear in mind with function returns is that you need to include the variable type you want to return as a suffix to the function name .. e.g.

Function BLAH() - returns an int
Function BLAH#() - returns a float
Function BLAH.MyType() returns a custom type

Stevie

You can also use the return command to break out of a function and go back to where it was called from