Passing variables by reference?

BlitzMax Forums/BlitzMax Programming/Passing variables by reference?

ImaginaryHuman(Posted 2005) [#1]
I noticed in the documentation it says you can pass a variable by reference like:

Local myvar:Int=5

Function myfunction:Int(sameasmyvar Var)
   sameasmyvar:+2
   Return sameasmyvar
End Function

Print myvar

'Should print 7, right?

Ie instead of creating a new variable to pass the parameter into, it actually uses the one that was already defined outside of the function? So you can define a variable as a local outside the function and it will still be used as a Local inside the function?


Chris C(Posted 2005) [#2]
you're not actually running myfunction...

Local myvar:Int=5

print

myfunction(myvar)
Print myvar

Function myfunction:Int(sameasmyvar Var)
sameasmyvar:+2
' Return sameasmyvar
End Function