Sign in to follow this  
Followers 0
D3r1ck

Splitting text. [Need Help]

9 posts in this topic

#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. 

 

Share this post


Link to post
Share on other sites



Use _arraydisplay($array) between line 3 and 4 and it will explain a lot

Share this post


Link to post
Share on other sites

#3 ·  Posted (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 by D3r1ck

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites
#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

Share this post


Link to post
Share on other sites

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.

1 person likes this

AutoIt Absolute Beginners    Require a serial    Pause Script    Video Tutorials by Morthawt   ipify 

Monkey's are, like, natures humans.

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