Newbie2 Posted February 8, 2004 Share Posted February 8, 2004 Hey Guys... I have been using AutoIt for 1 week now. It's a great tool but I couldn't manage Arrays. I am trying to allocate to an array (which it's length will be randomly determined) a Random number and after that to read it or display it on a MsgBox. Here is what I have done so far... $arrayLength=(1,20); will determine the array dimention For $loop=1 to $arrayLength $myRandNumber=Random (0,9) ; here I should pusd 'myRandNumber' to the array Next Msgbox (0,"",?); Here all my array elements should be displayed Thanks for the help! Link to comment Share on other sites More sharing options...
GrahamS Posted February 8, 2004 Share Posted February 8, 2004 Try the following:$arrayLength=20; Dim $array[$arrayLength] For $loop=0 to $arrayLength-1 $myRandNumber=Random (0,9) $array[$loop] = $myRandNumber Next $string = "" For $loop=0 to $arrayLength - 1 $string = $string & $array[$loop] & " " Next Msgbox (0,"",$string); Here all my array elements should be displayed Notes:1. Not quite sure what you where trying to do with the $arrayLength=(1,20); statement. It isn't legal as is. I've replaced it with a single value2. The loops go from 0 to $arrayLength - 1 because AutoIt arrays start at zero3. AFAIK there is no statement to print out an array directly. I've added a loop to concatonate the array elements into a string for output4. If you don't need $myRandNumber for any thing then you can simply assign directly to the array element (i.e. $array[$loop] = Random(0,9) ) GrahamS Link to comment Share on other sites More sharing options...
Newbie2 Posted February 8, 2004 Author Share Posted February 8, 2004 Thanx GrahamS, I got it. I have another little question. The following returned an error. Why? Dim $myArray [3] For $loop=0 to 3 $myRandNumber=Random (1,9) $myArray [$loop] = $myRandNumber Next 10x again... Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2004 Developers Share Posted February 8, 2004 (edited) Thanx GrahamS, I got it. I have another little question. The following returned an error. Why? Dim $myArray [3] For $loop=0 to 3 $myRandNumber=Random (1,9) $myArray [$loop] = $myRandNumber Next 10x again...Thats because from 0 to 3 is 4 steps.... Edited February 8, 2004 by JdeB SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Newbie2 Posted February 8, 2004 Author Share Posted February 8, 2004 As usual, :iamstupid: Link to comment Share on other sites More sharing options...
Developers Jos Posted February 8, 2004 Developers Share Posted February 8, 2004 As usual, :iamstupid:nee.... just every now and then you ... thats all.. SciTE4AutoIt3 Full installer Download page - Beta files Read before posting How to post scriptsource Forum etiquette Forum Rules Live for the present, Dream of the future, Learn from the past. Link to comment Share on other sites More sharing options...
Administrators Jon Posted February 8, 2004 Administrators Share Posted February 8, 2004 I'm still glad I started the arrays at 0 and not 1 because it makes using the StringSplit type functions all the more easy Deployment Blog: https://www.autoitconsulting.com/site/blog/ SCCM SDK Programming: https://www.autoitconsulting.com/site/sccm-sdk/ 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