Page 1 of 1

Passing a multi dim in a function

PostPosted: June 16th, 2007, 7:32 pm
by Christine123
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

PostPosted: June 17th, 2007, 4:55 am
by Kambiz
Code: Select all
type
  TMyArray: array[0..100,0..100] of double;

var
  Properties: TMyArray;

procedure DisplayProperties(const Properties: TMyArray);

PostPosted: June 17th, 2007, 9:37 pm
by Christine123
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

PostPosted: June 17th, 2007, 10:13 pm
by Christine123
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

PostPosted: June 18th, 2007, 10:18 am
by Kambiz
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.