Solved

length of a multi dim array

Posted on 2009-05-11
7
359 Views
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);

....

begin

....    

      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]));

 

 

 

end;

Open in new window

0
Comment
Question by:BdLm
  • 3
  • 2
  • 2
7 Comments
 
LVL 26

Accepted Solution

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

Eg:

var  x:             TImageFilterREAL;
     dim1, dim2:    Integer;
begin

  SetLength(x, 10, 20);

  dim1:=Length(x);
  dim2:=Length(x[0]);

// dim1 = 10
// dim2 = 20

Regards,
Russell

0
 
LVL 36

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
Comment Utility
why not use a Variant ?
0
 
LVL 26

Expert Comment

by:Russell Libby
Comment Utility
What would be the reason for a variant if the author is only storing real values? Its 10 additional bytes per entry.
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 8

Author Closing Comment

by:BdLm
Comment Utility
I tried myseld also with length(X[0]) and failed, now this is working, maybe I had a typo ...
0
 
LVL 36

Expert Comment

by:Geert Gruwez
Comment Utility
it's more flexible for multidim arrays (and yes, ... slower too)
i just suggested a option
0
 
LVL 8

Author Comment

by:BdLm
Comment Utility

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


http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_21467468.htm



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

Expert Comment

by:Geert Gruwez
Comment Utility
i guess that would be with l at the end
http://www.experts-exchange.com/Q_21467468.html
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

771 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

9 Experts available now in Live!

Get 1:1 Help Now