Jump to content

StringSpilt with Array Variable doesnt work?!


JohnWang
 Share

Recommended Posts

hi..

i have a little problem with the stringsplit function with array variable. an Example of Error code:

dim $RegPath[5]dim $TestString = "HI|THIS|IS|A|TEST|"

$RegPath[2] = StringSplit($TestString,"|",1)

MsgBox(0,"Testing",$RegPath[2][0])

gave error:Array variable has incorrect number of subscripts or subscript dimension range exceeded at RegPath[2][0]

But this one works:

dim $RegPath

dim $TestString = "HI|THIS|IS|A|TEST|"

$RegPath = StringSplit($TestString,"|",1)

MsgBox(0,"Testing",$RegPath[0])

So apparantly the stringSplit accepted a normal variable; however, it doesnt seem to like the array varaible =( my question is, is it not possible to do a stringsplit with a array variable? or am i just not doing it right.. if thats the case how would fix the problem? Any help is appreciately....
Link to comment
Share on other sites

  • Moderators

dim $TestString = "HI|THIS|IS|A|TEST|"

dim $RegPath[5]
$RegPath[2] = StringSplit(StringTrimRight($TestString, 1),"|")
MsgBox(0, 'Test', UBound($RegPath[2]) - 1)

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Link to comment
Share on other sites

Somke thanks 4 the help ,but i think you misunderstand me or i didnt word it right(My mistake). I want to find not only the size of the array but be able to access all the variables inside the muti-demensional array-variables meaning "THIS,IS,A,TEST". The reason is that i have a file contains some registry keys and is formated liek this

HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\Explorer|NoSimpleStartMenu|dword|00000001

and i wanted to use the stringsplit to seperate the parts and use a for loop to write them into the registry for me, but so far making my tastk easier and i can just update the library and the program's function expands. Anyways Thanks in advance
Link to comment
Share on other sites

  • Moderators

dim $TestString = "HI|THIS|IS|A|TEST|ONLY|A|TEST|"
dim $RegPath[5]
$RegPath[2] = StringSplit(StringTrimRight($TestString, 1),"|")
CheckArray($RegPath[2])

Func CheckArray(ByRef $nArray)
    For $i = 1 To UBound($nArray) - 1
        MsgBox(0, 'Test ' & $i, $nArray[$i])
    Next
EndFunc

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

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