Yes.
Local myArray[10],i
For i=1 To 10
myArray[i]=i
Next
SquareArray myArray
PrintArray myArray
WaitKey
End
Function SquareArray(ar[10])
Local i
For i=1 To 10
ar[i]=ar[i]*ar[i]
Next
End Function
Function PrintArray(ar[10])
Local i
For i=1 To 10
Write " "+ar[i]
Next
Print ""
End Function
The array is passed to the function by name only. The array parameter to the function must have the same type and size as the original array. Most importantly, the array isn't copied - it's passed directly, and altered in place (if it's altered) by the receiving function, as demonstrated above.
Incidentally, there's a really neat use for this when porting annoying C code, too. Where a C function takes a variable by reference so it can return multiple values, you can declare an array of size 0 and pass it to the receiving function. Since Blitz optimises numeric constants, this is nearly as fast as using a normal local variable and lets you return as many variables from a function as you like! Saves having to rewrite the whole function to return objects or single values only.
|