length of a multi dim array

Posted on 2009-05-11
Last Modified: 2012-05-06
 Is use   TImageFilterREAL =  array of array of Real; in many procedure I shift theses data through all my code.  I do not want to pass the dim. of this array also between the procedure calls

How to get the length of an multidimensional array, the length command just uses the
length of the first array
type ;
         TImageFilterREAL =  array of array of Real;
procedure LoadArrayfromCSVFile(aFilename: String; aImageFilterREAL : TImageFilterREAL);
      setlength( aImageFilterREAL, CSVWordlist.Count, CSVFile.Count);
here comes the problem 
            LoadArrayfromCSVFile(myOpenDialog.FileName,  aImageFilterREAL );
                            //  another array     //  use second dim of this array 
            setlength(MyScaleData,          length(  aImageFilterREAL[0]));

Open in new window

Question by:BdLm
  • 3
  • 2
  • 2
LVL 26

Accepted Solution

Russell Libby earned 450 total points
ID: 24356330
Because both dimension are open, you need to check one of the elements for its length.


var  x:             TImageFilterREAL;
     dim1, dim2:    Integer;

  SetLength(x, 10, 20);


// dim1 = 10
// dim2 = 20


LVL 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
ID: 24358301
why not use a Variant ?
LVL 26

Expert Comment

by:Russell Libby
ID: 24358503
What would be the reason for a variant if the author is only storing real values? Its 10 additional bytes per entry.
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.


Author Closing Comment

ID: 31580209
I tried myseld also with length(X[0]) and failed, now this is working, maybe I had a typo ...
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24362119
it's more flexible for multidim arrays (and yes, ... slower too)
i just suggested a option

Author Comment

ID: 24362153

Ps:  for adding elements at the beginng at at the end ->

may be It would better to use a TList  :-( after coding many lines .....
LVL 37

Expert Comment

by:Geert Gruwez
ID: 24362168
i guess that would be with l at the end

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

816 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now