Jump to content

Splitting text. [Need Help]


D3r1ck
 Share

Go to solution Solved by Spider001,

Recommended Posts

#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

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

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

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

#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

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.

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

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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...