jslegers Posted May 12, 2006 Share Posted May 12, 2006 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 ? Link to comment Share on other sites More sharing options...
nfwu Posted May 12, 2006 Share Posted May 12, 2006 Errm... like this?: $string = $r[0] &","&$r[1]&","&$r[2]&","&$r[3]&","&$r[4]&","&$r[5]&","&$r[6] #) TwitterOut of date stuff:Scripts: Sudoku Solver | Webserver | 3D library (Pure AutoIt) | Wood's GadgetsUDFs: _WoodUniqueID() | _DialogEditIni() | _Console*() | _GetIPConfigData() | _URLEncode/Decode() Link to comment Share on other sites More sharing options...
jslegers Posted May 12, 2006 Author Share Posted May 12, 2006 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. Link to comment Share on other sites More sharing options...
JerryD Posted May 12, 2006 Share Posted May 12, 2006 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.See the post _ArrayRandomize UDF, Load a one dimension array with random numbers Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now