Return

Blitz3D Forums/Blitz3D Programming/Return

Jerome Squalor(Posted 2007) [#1]
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!


mindstorms(Posted 2007) [#2]
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.


Jerome Squalor(Posted 2007) [#3]
Ohhhh...Thanks so much, i've been trying to figure that out for so long!


Stevie G(Posted 2007) [#4]
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


boomboom(Posted 2007) [#5]
You can also use the return command to break out of a function and go back to where it was called from