# Combine 2 variable names in "for" command.

## Recommended Posts

In LUA you can in a FOR loop combine a variable with the current in the loop like;

for i=9,0,-1 do VAR = "hello"

is it possible to do this in autoit?

The first thing that came to my mind was

For \$i = 5 to 1 Step -1

\$VAR[\$i] = "hej"

Next

MsgBox(0,"", \$VAR1, \$VAR2, \$VAR3, \$VAR4, \$VAR5)

but doesnt seem to wok

[center][u]WoW Machinima Tool[/u] (Tool for Machinima Artists) [/center]

##### Share on other sites

add an & sign for example

for loop example

```Global \$var[4]
\$var[1] = "hi "
\$var[2] = "my name is "
\$var[3] = "thatsgreat2345"
For \$i = 1 to 3
MsgBox(0,"Combining Variables",\$var[\$i])
Next

oÝ÷ Ù«­¢+Ø(ÀÌØíÙÈÄôÅÕ½Ðí¡¤ÅÕ½Ðì(ÀÌØíÙÈÈôÅÕ½Ðíµä¹µ¥ÌÅÕ½Ðì(ÀÌØíÙÈÌôÅÕ½ÐíÑ¡ÑÍÉÐÈÌÐÔÅÕ½Ðì)5Í    ½à À°ÅÕ½Ðí
½µ¥¹¥¹YÉ¥±ÌÅÕ½Ðì°ÀÌØíÙÈÄµÀìÀÌØíÙÈÈµÀìÀÌØíÙÈÌ¤(```
Edited by thatsgreat2345

##### Share on other sites

Not really understanding what you're getting at, but I wouldn't doubt it doesn't work, You didn't declare your Array, you didn't use the Array in the msgbox (the numbers in brackets) and you have too many parameters for your msgbox

```Dim \$Array[10], \$blah
For \$i = 9 To 0 Step - 1
\$Array[\$i] = 'SomeText ' & \$i
\$blah &= \$Array[\$i] & @CR
Next
\$blah = StringTrimRight(\$blah, StringLen(@CR))
MsgBox(64, 'Info', \$blah)```

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...