MM Basic - two-dimensional arrays in functions

I want to copy a two-dimensional array (8,8) in Picomite. Since I want to do this several times in a row with different source and target arrays, I want to use a function.
Unfortunately, I keep getting error messages at the call (syntax and dimensions) and can’t find any examples in the manual.
Here is the function:

Function Raster_kopieren(Quelle As Integer(1 to 8, 1 to 8)) As Integer(1 to 8, 1 to 8)
Dim arrErgebnis(8, 8) As Integer
Dim r As Integer, c As Integer
For r = 1 To Zeilen
For c = 1 To Spalten
arrErgebnis(r, c) = Quelle(r, c)
Next c
Next r
Return arrErgebnis
End Function

Here is the call:

temporaeres_Raster() = Raster_kopieren(intWert(1 to 8, 1 to 8))

Does anyone have any advice?

I don’t understand what you are trying to do but this isn’t remotely valid syntax. The way to pass an array to a function is Quelle(). Also, MMBasic can’t return arrays from a function. To modify an array in a function you need to include it in the argument list. All arrays are passed by reference so any changes made in the function will be then be seen outside. You also need to understand OPTION BASE and use it as appropriate for your application.

Variables in the main program are automatically global in scope. To change the array, just change the elements in the SUB or FUNCTION.

dim a(3,3)
b=myfun()
print a(1,1)
print b
end
function myfun()
a(1,1)=pi
myfun=10
end function

run
3.14159...
10
run

You don’t need to include arrays in the parameter list. Arrays (and any other variables) defined in the main program are global so any changes made to the array in a SUB or FUNCTION will still be there when the SUB or FUNCTION returns.

Yes but not great practice. Better to pass the array as a parameter then you can use the same function for different source arrays

Agreed. Pass by reference is in many cases a better choice than directly accessing something as a global, as it allows using the same subroutine/function to be used with multiple things in a controlled fashion.

I agree with that but you said,
To modify an array in a function you need to include it in the argument list.
and that is simply not true.