Passing a multi dim in a function

Please discuss general Delphi programming topics here.

Passing a multi dim in a function

Postby Christine123 » June 16th, 2007, 7:32 pm

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
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Kambiz » June 17th, 2007, 4:55 am

Code: Select all
type
  TMyArray: array[0..100,0..100] of double;

var
  Properties: TMyArray;

procedure DisplayProperties(const Properties: TMyArray);
Kambiz
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm

Postby Christine123 » June 17th, 2007, 9:37 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
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Christine123 » June 17th, 2007, 10:13 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
Junior Member
 
Posts: 25
Joined: May 28th, 2007, 10:28 pm

Postby Kambiz » June 18th, 2007, 10:18 am

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
User avatar
Kambiz
Administrator
Administrator
 
Posts: 2429
Joined: March 7th, 2003, 7:10 pm


Return to Delphi Programming

Who is online

Users browsing this forum: No registered users and 22 guests

cron