# Getting Variables Out Of An Array ?

## Recommended Posts

Hi,

I have the folowing script :

#include <Array.au3>

Dim \$R[7]

Dim \$Num1

Randomize()

_ArrayDisplay( \$R, " Array")

MsgBox (0, "Test", \$Num1)

Func Randomize()

\$R[1] = Random(1, 45, 1)

\$R[2] = Random(1, 45, 1)

\$R[3] = Random(1, 45, 1)

\$R[4] = Random(1, 45, 1)

\$R[5] = Random(1, 45, 1)

\$R[6] = Random(1, 45, 1)

If \$R[1] = \$R[2] Or \$R[1] = \$R[3] Or \$R[1] = \$R[4] Or \$R[1] = \$R[5] Or \$R[1] = \$R[6] Then Randomize ()

If \$R[2] = \$R[3] Or \$R[2] = \$R[4] Or \$R[2] = \$R[5] Or \$R[1] = \$R[6] Then Randomize ()

If \$R[3] = \$R[4] Or \$R[3] = \$R[5] Or \$R[1] = \$R[6] Then Randomize ()

If \$R[4] = \$R[5] Or \$R[1] = \$R[6] Then Randomize ()

_ArraySort(\$R, 0, 1)

\$Getal1 = _ArrayToString (\$R, 1, )

EndFunc

This script generates a Array with 7 numbers between 1 and 45. How can I get a value out of an Array and put it in a string. I want to do this because the array is sorted. For example I want to create variables like this

\$Num1 = _ArrayToString (\$R, 1, 1, )

\$Num2 = _ArrayToString (\$R, 2, 2, )

\$Num3 = _ArrayToString (\$R, 3, 3, )

\$Num4 = _ArrayToString (\$R, 4, 4, )

\$Num5 = _ArrayToString (\$R, 5, 5, )

\$Num6 = _ArrayToString (\$R, 6, 6, )

\$Num7 = _ArrayToString (\$R, 7, 7, )

Is this posible ?

##### Share on other sites

Errm...

like this?:

`\$string = \$r[0] &","&\$r[1]&","&\$r[2]&","&\$r[3]&","&\$r[4]&","&\$r[5]&","&\$r[6]`

#)

##### Share on other sites

Errm...

like this?:

`\$string = \$r[0] &","&\$r[1]&","&\$r[2]&","&\$r[3]&","&\$r[4]&","&\$r[5]&","&\$r[6]`

#)

Thanks this is what I was searching for. Thanks a lot.
##### Share on other sites

Your post intrigued me, and I ended up writing a full UDF that loads a one dimension array with random numbers with lots of options.

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

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