## Passing a multi dim in a function

Please discuss general Delphi programming topics here.

### Passing a multi dim in a function

I have a static multi Dim array:

Properties: array[0..100,0..100] of double;

I would like to write a function where I have to pass this multdim array.
what is the declaration?

Function DisplayProperties(Properties: array of double) // doesn't work
Fucntion DisplayProperties(Properties: array of array of double) // doesn't work too

If anyone would be able to help me out, I'd greatly appreciate it.
Christine
Christine123
Junior Member

Posts: 25
Joined: May 28th, 2007, 10:28 pm

Code: Select all
type   TMyArray: array[0..100,0..100] of double;var  Properties: TMyArray;procedure DisplayProperties(const Properties: TMyArray);
Kambiz

Kambiz

Posts: 2430
Joined: March 7th, 2003, 7:10 pm

Kam,

Thank you for the reply. I have declared the 2 dimen array and a type and called it TMyarray in the main. However when I am writing what I want my function to do, the function doesn't understand what a TMyarray is. How would I get around this?

Christine
Christine123
Junior Member

Posts: 25
Joined: May 28th, 2007, 10:28 pm

It's kinda wierd how you can declare a single array in the main, write a fucntion called MyFunction(x: array of double) and it works, however you can declare a 2 D array in the main, but CANNOT write a fucntion MyFunction(x:array of array of double). It's really weird how you can't pass 2D arrays.

I then tried the following code but I received an error.
type
TMyArray: array[0..100,0..100] of double;

var
Properties: TMyArray;

I then in the main wrote.
Type
TwoDarray = record
TMyArray: array[0..100,0..100] of double;

my fucntion that I wrote was MyFunction(x: TwoDArray) , however in the unit where the function was declared it didn't recognize what a TwoDArray was
Christine123
Junior Member

Posts: 25
Joined: May 28th, 2007, 10:28 pm

Christine123 wrote:II then tried the following code but I received an error.
type
TMyArray: array[0..100,0..100] of double;

var
Properties: TMyArray;

What was the error?

Christine123 wrote:I then in the main wrote.
Type
TwoDarray = record
TMyArray: array[0..100,0..100] of double;

my fucntion that I wrote was MyFunction(x: TwoDArray) , however in the unit where the function was declared it didn't recognize what a TwoDArray was

Declaration of TwoDarray seems to be wrong. Consults Delphi's help for proper declaration of record data type.
Kambiz

Kambiz