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...
Hope it makes 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...