3

hi i Have a problem when I use a two dimensional dynamic array. I use this: procedure ListDeleted(FilesList: array of array of Integer); Delphi give me compile error How can I fix it?

1
  • 1
    if you have found an answer which worked for you, you should choose it as the accepted answer (by clicking on the tick mark next to it) Commented Nov 23, 2010 at 11:23

2 Answers 2

12

Declare the array type first, then use it in the parameter list

type
  T2DIntArr = array of array of Integer;

...

ListDeleted(FilesList: T2DIntArr);
Sign up to request clarification or add additional context in comments.

1 Comment

@micheal, if this is the answer which worked for you, you should choose it as the accepted answer (by clicking on the tick mark next to it).
3

Define a custom type:

type
  TIntArray2 = array of array of Integer;

If you just read the parameter content in ListDeleted, use

 procedure ListDeleted(const FilesList: TIntArray2)

If the parameters are about to be modified internaly , use

 procedure ListDeleted(var FilesList: TIntArray2)

If the parameters are to be modified internally, but the modification should not be propagated to the caller, use

 procedure ListDeleted(FilesList: TIntArray2)

But notice that the last declaration (with no const nor var) will make a temporary copy of the array before calling ListDeleted, which is not a good idea for performance.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.