Sign in to follow this  
Followers 0
DarkNecromancer

array problem

3 posts in this topic

#1 ·  Posted (edited)

hay i was making a program installer and i want my program to convert a string to an array. so i made a while loop to move each individual character over but i get a strange error:

For $e = 0 To 15
                Local $thekey[$e] = StringLeft ( $key, 1)
                $len = StringLen ( $key) 
                $key = StringRight ( $key, ($len - 1))
            Next
and i get the error:

Local $thekey[$e]= StringLeft ( $key, 1)

Local $thekey[^ ERROR

Error: Array variable subscript badly formatted.

I've gone over the help file and i can't see any varient in my version from the one provided in the help file :ph34r: Edited by DarkNecromancer

Share this post


Link to post
Share on other sites



Try using the following instead:

Dim $thekey

; The delimiter is a null string
$thekey = StringSplit( $key, "" )

Per the StringSplit() documentation:

If you use a blank string "" for the delimiters, each character will be returned as an element.

It should do what you are talking about. If you really think you need to do a loop then do not declare the array inside the loop. Try this:

Dim $e
Dim $thekey[StringLen($key)]

For $e = 0 to ( UBound($thekey) - 1 )

   $thekey[$e] = StringMid( $key, ($e + 1), 1)

Next

Both code segments have been tested and work. I hope this is what you are looking for, Happy Posting!

*** Matt @ MPCS

Share this post


Link to post
Share on other sites

OOoO :ph34r: thanks, didn't see that :( Still learning all the commands of V3 :\

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