function returns

Blitz3D Forums/Blitz3D Beginners Area/function returns

Second Chance(Posted 2003) [#1]
Do commands after function returns get executed after the function returns its return info?

ex.
Function Blah()
x$ = "xBlah"
return x$
x$ = ""
end function

Would this function return "xBlah" before clearing the variable?


Anthony Flack(Posted 2003) [#2]
Why not run it and find out?

But I think, if I remember rightly, that Return will terminate the function then and there, so x$ should still equal xBlah at the end.


soja(Posted 2003) [#3]
Yes, Return short circuits any function (as opposed to setting the return value for End Funtion to return... which is the only other situation I can think of which might conceivably make sense for Return to do...)


Second Chance(Posted 2003) [#4]
That's what it does alright, thanks guys :)


Neo Genesis10(Posted 2003) [#5]
Remember that you also need to declare the type of information your function will return. For example: x$ = GetData$() and p1.playertype = NewPlayer.playertype().


Second Chance(Posted 2003) [#6]
Ok, thanks.