Bagjan Wiedus Posted July 6, 2006 Posted July 6, 2006 Dear all, I am using StringSplit to put 1,2 or 3 names in an array like: $users = StringSplit ( $templine, " ") The problem is when I want to do: $user=$users[3] and $users[3] is not filled/used my script exits with the following error message: E:\srksim\autoit\domain\Add_domain_user.au3 (228) : ==> Array variable has incorrect number of subscripts or subscript dimension range exceeded.: $userlen3=StringLen($users[3]) $userlen3=StringLen(^ ERROR Does anyone now how to count the number of rows in an array that are really filled (Ubound is counted the number of rows that exist) Kind regards Jan
MHz Posted July 6, 2006 Posted July 6, 2006 (edited) StringSplit is dynamic with creating arrays. Element [0] has the amount of elements. ; The created array holds the count in $array[0] $array = StringSplit('1|2|3|4|5', '|') For $i = 1 To $array[0] MsgBox(0, '', $array[$i]) Next StringSplit does not need UBound() to test the amount of elements. Edit: More text for understanding added Ohh, and welcome to the forum. Edited July 6, 2006 by MHz
randallc Posted July 6, 2006 Posted July 6, 2006 Hi, You are using ubound() as an item; the last item will be numbered ubound()-1; So... above is SAME as.. ; The created array holds the count in $array[0] $array = StringSplit('1|2|3|4|5', '|');6 items will be 0,1,2,3,4,5, the last will be $array(6-1) For $i = 1 To ubound($array)-1 MsgBox(0, '', $array[$i]) Next (ie, after "stringsplit", ubound($array)-1=$array[0], and no such item as"$array[ubound($array)] ") ExcelCOM... AccessCom.. Word2... FileListToArrayNew...SearchMiner... Regexps...SQL...Explorer...Array2D.. _GUIListView...array problem...APITailRW
Bagjan Wiedus Posted July 7, 2006 Author Posted July 7, 2006 Thanks guys, I did not now that the number of cells was stored in the first [0]. I am quite a newbie in autoit. Kind regards, Jan
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