Notifications
Clear all

[Closed] simple quistion

Hi everybody …
im starting to learn maxscript …
and i got this question :

for x = 1 to 5 do
(
???
)

i want inside the loop to create variable called (a+the x value from the loop)

a1
a2
a3
a4
a5

4 Replies

You can’t do it. Try with arrays – in loop fill the array and use its elements as variables.

 lo1

The more important answer is “there is no reason you should want to do it”.


codeTxt = ""
for x = 1 to 5 do
(
codeTxt += "a" + ( i as string) + " = undefined 
"
)

execute codeTxt

 em3

arrays are your friend
multi-dimensional arrays are your girlfriend


(
varr = for a = 1 to 5 collect #(a,a*(random 4 10)) 
for v = 1 to varr.count do format "% <-- value of a	 product of a*% --> %
" varr[v][1] (varr[v][2]/varr[v][1]) varr[v][2]
)


beware: girlfriends can drive you mad