array as parameter

BlitzMax Forums/BlitzMax Beginners Area/array as parameter

if you pass an array as a parameter, is a reference to the original array sent

Yes, it is sent as a pointer, just like all BlitzMax type instances/objects.

If you want to work on a copy of an array, just make a temporary copy at the start of the function using slicing. See this example below:

Local myArray:Int[] = [0, 1, 2, 3, 4 ]
ChangeArray(myArray)
ChangeArrayCopy(myArray)
Print myArray[1]

Function ChangeArray( pArray:Int[] )
	pArray[1] = -1
EndFunction

Function ChangeArrayCopy( pArray:Int[] )
	pArray = pArray[..]		'We can quickly make a copy of the array using slicing
	pArray[1] = -2
EndFunction