?
Solved

3D Dynamic Array

Posted on 2010-01-11
6
Medium Priority
?
251 Views
Last Modified: 2012-05-08
Hello,
I have a problem with 3d dimensional dynamic array.How could i set each dimension seperatly.String value

Something 0
Another 0
That 0
Another 1
That 0
procedure TForm1.Button1Click(Sender: TObject);
var
i,j,l:integer;
 multiArray : Array of Array of array of string;
begin
  // Set the length of the 1st dimension of the multi-dim array
  SetLength(multiArray,10);

  // Set the length of the 3 sub-arrays
  SetLength(multiArray[0],5);
  SetLength(multiArray[1],5);
  SetLength(multiArray[2],5);

  SetLength(multiArray[0][0],1);
  SetLength(multiArray[1][1],1);
  SetLength(multiArray[2][2],1);


  // Set elements of this array
  multiarray[0,0,0]:='a'; //<< only sets last dimension
end;

Open in new window

0
Comment
Question by:prasiddutta
  • 3
  • 2
6 Comments
 
LVL 12

Expert Comment

by:Hypo
ID: 26285289
Could you rephrase your question, or give more examples of what you would like acheive? I really don't understand what you are trying to do... which makes it hard to help...
0
 

Author Comment

by:prasiddutta
ID: 26285351
How could i set each dimension separately string value??
0
 
LVL 23

Expert Comment

by:Ferruccio Accalai
ID: 26285620
Prasiddutta this is not rephrasing but just repeating.
We are not blind, we just need to understand you and honestly is difficult to understand what you are asking for.

In your code what do you mean with the last line?

 multiarray[0,0,0]:='a'; //<< only sets last dimension

'a' is a string, not a value for a dimension...

Any example, as already asked by Hypo?
0
Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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.

 

Author Comment

by:prasiddutta
ID: 26290214
I mean how to set value for each dimension like

string value?
0
 
LVL 23

Accepted Solution

by:
Ferruccio Accalai earned 2000 total points
ID: 26291063
Mmm, again repeated the same question in the same way so it's difficult to understand.
as you set each dimension you can set also the values

Let's say that you have a multiarray [x,y,z]
where x, y and z legths are 20

this code will write a different char in every element

var
a,i,j,l: Integer;
begin
a := 97;
for i := 0 to High(MultiArray) do
   for j := 0 to High(Multiarray[i]) do
      for l := 0 to High(MultiArray[j]) do
         begin
            MultiArray[i,j,l] := char(a);
            inc(a);
         end;
end;

0
 

Author Closing Comment

by:prasiddutta
ID: 31675580
Your example is very clear to understand...
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

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 is an update to some code that someone else posted on Experts Exchange. It is an alternate approach, I think a little easier to use, & makes sure that things like the Task Bar will update.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
The video will let you know the exact process to import OST/PST files to the cloud based Office 365 mailboxes. Using Kernel Import PST to Office 365 tool, one can quickly import numerous OST/PST files to Office 365. Besides this, the tool also comes…
Suggested Courses
Course of the Month3 days, 6 hours left to enroll

600 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