D3r1ck Posted January 26, 2015 Share Posted January 26, 2015 #include <Array.au3> $rarray = InputBox("","Create an array") $array = StringSplit($rarray, " ") for $i = $array[0] to 10 $array[$i] = " " Next ConsoleWrite($array[3]) Im trying to fill the array to 10 and keep running into errors. The reason im trying to do this is later in the script i might access $array[6] and if it isnt filled all the way to six it will error out. Link to comment Share on other sites More sharing options...
Spider001 Posted January 26, 2015 Share Posted January 26, 2015 Use _arraydisplay($array) between line 3 and 4 and it will explain a lot Link to comment Share on other sites More sharing options...
D3r1ck Posted January 26, 2015 Author Share Posted January 26, 2015 (edited) I have used _ArrayDisplay. I am familiar with arrays. Say i input a string= one two three four That is going to return an array of $array[4] and $array[0] will = 4. The loop is trying to fill up the rest of the array to $array[10] with a space. However i get an error message and im not sure why im getting it. "C:UsersDerickDesktopAutoITTestsarrays.au3" (5) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $array[$i] = " " ^ ERROR Edited January 26, 2015 by D3r1ck Link to comment Share on other sites More sharing options...
JohnOne Posted January 26, 2015 Share Posted January 26, 2015 (edited) How can you fill a 4 element array up to a non existent 10th element? I am familiar with arrays No, no you are not, you need to read the basics. Edited January 26, 2015 by JohnOne AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. Link to comment Share on other sites More sharing options...
D3r1ck Posted January 26, 2015 Author Share Posted January 26, 2015 How can you fill a 4 element array up to a non existent 10th element? No, no you are not, you need to read the basics. In the post you quoted i meant to put a the. "I have used _ArrayDisplay and am fimiliar with the arrays" Meaning the particular arrays im working with i am familiar with. As for the script i am asking for help with, it has been taken out of context and is an example. Any help is much appriciated. Link to comment Share on other sites More sharing options...
Solution Spider001 Posted January 26, 2015 Solution Share Posted January 26, 2015 https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayAdd.htm Link to comment Share on other sites More sharing options...
D3r1ck Posted January 26, 2015 Author Share Posted January 26, 2015 https://www.autoitscript.com/autoit3/docs/libfunctions/_ArrayAdd.htm THANK YOU! You are the most helpful person that has entered this thread. Thank the lord you exist. I have been looking for exactly this function for a long time. Link to comment Share on other sites More sharing options...
D3r1ck Posted January 26, 2015 Author Share Posted January 26, 2015 #include <Array.au3> $rarray = InputBox("","Create an array") $array = StringSplit($rarray, " ") for $i = Ubound($array) - 1 to 10 $array[0] = $i _ArrayAdd($array, " ") Next For $i = 0 to 10 ConsoleWrite($array[$i] & @CRLF) Next Link to comment Share on other sites More sharing options...
JohnOne Posted January 26, 2015 Share Posted January 26, 2015 In the post you quoted i meant to put a the. "I have used _ArrayDisplay and am fimiliar with the arrays" Meaning the particular arrays im working with i am familiar with. As for the script i am asking for help with, it has been taken out of context and is an example. Any help is much appriciated. Best thing you can do here when looking for help, is only say exactly what you mean and try to be as precise as you possibly can. I never offered further code help as I thought you were actually familiar working with arrays, and you just made a schoolboy error, I suspect the poster above thought the same. Sorry I got you wrong, no harm done. Spider001 1 AutoIt Absolute Beginners Require a serial Pause Script Video Tutorials by Morthawt ipify Monkey's are, like, natures humans. 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