Solved

# 3D Dynamic Array

Posted on 2010-01-11
Medium Priority
251 Views
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;
``````
0
Question by:prasiddutta
• 3
• 2

LVL 12

Expert Comment

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

ID: 26285351
How could i set each dimension separately string value??
0

LVL 23

Expert Comment

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...

0

Author Comment

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

string value?
0

LVL 23

Accepted Solution

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

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

## Featured Post

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