question about array

question about array

Anonymous
Not applicable
464 Views
3 Replies
Message 1 of 4

question about array

Anonymous
Not applicable
Hi! I am biginner of maxscripts.
I want to create 2D array.
so, I wrote the code under.

inex=#()
linesx=#()
for k= 1 to 3 do
(
for j = 1 to 3 do
(
linex=j*k
)
linesx=linex
)

The answer of linesx I expected is
#(#(1, 2, 3), #(2, 4, 6), #(3, 6, 9))

but answer is
#(#(3, 6, 9), #(3, 6, 9), #(3, 6, 9))

Is there some mistake in my code?

To try
inex=#()
linesx=#()
for k= 1 to 3 do
(
for j = 1 to 3 do
(
linex=j*k

)
linesx=linex
break()
)
When j=1 at breakpoint
linesx is #(#(1, 2, 3))

But j=2 at breakpoint
linesx is #(#(2, 4, 6), #(2, 4, 6))

I changed the code.

inex=#()
linesx=#()
for k= 1 to 3 do
(
for j = 1 to 3 do
(
linex=j*k
)
append linesx linex
)

But,answer is the same.

Please tell me how to write code answer "#(#(1, 2, 3), #(2, 4, 6), #(3, 6, 9))".
0 Likes
465 Views
3 Replies
Replies (3)
Message 2 of 4

Steve_Curley
Mentor
Mentor
Two important points.

Always state your Max version. Maxscript does vary depending on version (new features).
Always enclose code fragments within ... tags - the forum software can make a real mess of it if you don't.

(
myArray = #(#())

for j = 1 to 3 do
(
tmpArray = #()

for k = 1 to 3 do
tmpArray = j*k

myArray = tmpArray
)
)

Max 2016 (SP1/EXT1)
Win7Pro x64 (SP1). i5-3570K @ 4.4GHz, 8Gb Ram, DX11.
nVidia GTX760 (2GB) (Driver 430.86).

0 Likes
Message 3 of 4

Anonymous
Not applicable
Steve,Thank you
I understood your points.
0 Likes
Message 4 of 4

Anonymous
Not applicable

(
myArray = for j=1 to 3 collect (for k=1 to 3 collect j*k)
)
0 Likes