User Defined Types and Functions

Blitz3D Forums/Blitz3D Beginners Area/User Defined Types and Functions

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

When a variable is passed by reference any changes to the variable are kept when the function exits. In some small way its the same as using a global. The following psuedo (Blitz / VB hyrbid ) functions should make things clearer...

ammo = 47
ShootWeapon( ammo )
; ammo now equals 46

Function ShootWeapon( byREF ammo )
	ammo = ammo - 1	; Actually changes the value
	MakeBullet
End Function

ammo = 47
ammo = ShootWeapon( ammo )

Function ShootWeapon( byVAL ammo )
	MakeBullet
	Return ammo - 1	; Has to return the value
End Function

Hope it makes things clearer...