Solved

length of a multi dim array

Posted on 2009-05-11
7
363 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
ID: 24356330
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 37

Assisted Solution

by:Geert Gruwez
Geert Gruwez earned 50 total points
ID: 24358301
why not use a Variant ?
0
 
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.
0
Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
LVL 8

Author Closing Comment

by:BdLm
ID: 31580209
I tried myseld also with length(X[0]) and failed, now this is working, maybe I had a typo ...
0
 
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
0
 
LVL 8

Author Comment

by:BdLm
ID: 24362153

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 37

Expert Comment

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

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

820 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