;Blitz normally passes variables by value, with no way to pass by reference ;(short of using Globals, which negates the point of explicitly passsing them) a=100 b=10 Print "pre: "+a ; displays 100 Print "pre: "+b ; displays 10 foo(a,b) Print "post: "+ a ; displays 100 Print "post: "+b ; displays 10 Print"---" ;However, Types are always passed by reference Type bartype Field a Field b End Type bar.bartype=New bartype bar\a=100 bar\b=10 Print "pre: "+bar\a ; displays 100 Print "pre: "+bar\b ; displays 10 foobar(bar) Print "post: "+ bar\a ; displays 200 Print "post: "+bar\b ; displays 11 WaitKey End Function foo(a,b) a=200 ; these changes will not matter outside this function b=b+1 End Function Function foobar(baz.bartype) baz\a=200 ; these changes *will* matter outside this function baz\b=baz\b+1 End Function
This shows how the variables passed to foo() are not affected outside of foo() since only the *values* of a & b are passed to it, not "the real" a & b.
I would have expected your function to cause a problem when it tried to FreeImage a handle that had already been freed, but that doesn't happen:
Graphics 800,600 FreeImage 12345 ; just a number picked out of thin air FreeImage 12345 ; even worse, we're freeing this nonexistent handle twice! hdl=CreateImage(32,32) FreeImage hdl FreeImage hdl ; Blitz has no problem with this Print "No boom. Press a key." WaitKey End
(BTW, there's a similar discussion about "missing memory" for 3D at http://blitzbasic.com/bbs/posts.php?topic=25942 )