Array Method Parms

Is there a way to pass Arrays as Parms for a Method? For example:
A1 : Array[0…2, 0…3] of Integer = . . .
A2 : Array[0…4, 0…8] of Integer = . . .
DoIt(4, 8, A2); // Calling a Method DoIt:

Method DoIt(maxRow, maxCol : Integer, AnArray : Array)
Begin
For var iX = 0 to MaxRow Do Begin
For var iY = 0 to MaxCol Do Begin
DoSomething with AnArray[iX, iY]
End; //EndFOR iY
End; //EndFOR iX
End;//EndMETH DoIt

Maybe do it with Array Pointers if not Array Parms?

Thanks,
–tex

Sure, e.g.:

method DoIt(maxRow, maxCol : Integer, AnArray : array[0…2, 0…3] of Integer)

or

method DoIt(maxRow, maxCol : Integer, AnArray : array of Integer)

but you will need to provide the type, array alone is not a valid type.

So,
method DoIt(maxRow, maxCol : Integer, AnArray : array of Integer)

Will work for 2D arrays of different X & Y lengths being passed, even though the parm is only “array of Integer”?

Yes. That will take a Dynamic Array Pfänder, which a static array is assignment compatible to. Inside the method, you can use length() to determine the actual size of the array (it will always be zero-based).

For 2D array, you would need to declare the param type
array of array of Integer

Or you declare
Array of integer, and additional Len1, len2 parameter for the lengths.

Presumably, then, I can use a 3D Array of Integer by:

Method DoIt(maxX, maxY, maxZ : Integer, AnArray : Array of Integer) where AnArray can be considered as AnArray[0…maxX, 0…maxY, 0…maxZ)], right?
for a 4D by adding the length-1 of the 4th dimension?

Thanks, wuping. For my curiosity only: the name, wuping, looks Chinese to me. Are you Chinese? What country are you in? You need not answer. My 13yo daughter has been learning Chinese from an 8th grade girl in her class. She & family are 1st generation from China. Chinese people have an outstanding reputation in the US & I guess elsewhere.

I believe multi-dim would only work as fixed-size or as “array of array of Integer”, where you’d have to query the site for each level via length().

Yes.

What I had meant is - to put the 2D array data into a 1D array, while passing the 1D array together with dimensions len1 and len2, as an alternative to directly passing the param as array of array of integer. TensorFlow does this a lot - the internal data is just one big chunk of memory (as 1D array), but an additional Shape information is provided for the dimension information.

OK, guys, thanks. To simplify my life I’m only going to create 1D Arrays & Map them to 2D, 3D, 4D, … as I may need them. Modern computers are so fast the time lost is insignificant vs what a compiler could create directly. Saves any “()” vs “[]” concerns & eliminates a whole bunch of “()” or “[]” typing to initialize my arrays.