Sign in to follow this  
Followers 0
jslegers

Getting Variables Out Of An Array ?

4 posts in this topic

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 this post


Link to post
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 this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0