PDA

View Full Version : Multidimensional Array Error!


Tingspain
08-19-2006, 05:15 PM
Hello everybody, does anyone tell me what i am doing wrong in this code:

Thank in advance
_ting_



global temp = #(#())

-- Create The Reference Object
temp[1][1] = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 pos:[0,0,0] isSelected:off

-- Create the Muldimensional Array of copy of the object
for i=2 to 5 do
for j=2 to 5 do
temp[i][j] = copy temp[i-1][j-1]

-- In addition i dont know if use reference instead of copy method.

Bobo
08-20-2006, 04:40 AM
Hello everybody, does anyone tell me what i am doing wrong in this code:

Thank in advance
_ting_



global temp = #(#())

-- Create The Reference Object
temp[1][1] = Box lengthsegs:1 widthsegs:1 heightsegs:1 length:10 width:10 height:10 pos:[0,0,0] isSelected:off

-- Create the Muldimensional Array of copy of the object
for i=2 to 5 do
for j=2 to 5 do
temp[i][j] = copy temp[i-1][j-1]

-- In addition i dont know if use reference instead of copy method.


You are initializing just one sub-array in your top-level array. When you try to access element [2][2], it is undefined so you cannot access it as a 2D array.
You would have to first initialize the main array to have as many sub-arrays as you want in the first level. Then you can assign to the elements in these arrays using the two-index method as you are doing now...

CGTalk Moderation
08-20-2006, 04:40 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.