LoneWolf_2106 Posted July 4, 2017 Share Posted July 4, 2017 (edited) Dear everybody, i have created a function that searches for a string in an array and starting from that point(index), stores in another array the following 26 items. Func FileSearch($sStringToSearch) $k=0 $count_search=0 For $count = 0 To UBound($content_array) - 1 $search_result=StringInStr($content_array[$count],$sStringToSearch) If $search_result<>0 Then $count_search+=1 ReDim $SearchOnlineActivation[$count_search][$k] ;Adding a row MsgBox($MB_OK, "rows", UBound($SearchOnlineActivation, $UBOUND_ROWS)) For $k=0 To 25 ReDim $SearchOnlineActivation[$count_search][$k +1] ;Adding a column $SearchOnlineActivation [$count_search -1][$k] = $content_array[$count] $k+=1 ;_ArrayDisplay($SearchOnlineActivation) Next EndIf Next EndFunc The problem starts at this Point: $SearchOnlineActivation [$count_search -1][$k] = $content_array[$count] I insert a search_result in a cell of the 2D Array, but it "crashes". (Array variable has incorrect number of subscripts or subscript dimension range exceeded.) Edited July 4, 2017 by LoneWolf_2106 Link to comment Share on other sites More sharing options...
Danp2 Posted July 4, 2017 Share Posted July 4, 2017 Couple of thoughts -- 1) ReDim is slow. Move it out of your For loop and do it once instead of 25 times 2) If $k = 0, then $k - 1 = -1, which is an invalid subscript dimension. Try changing that line to $SearchOnlineActivation [$count_search -1][$k] = $content_array[$count] Latest Webdriver UDF Release Webdriver Wiki FAQs Link to comment Share on other sites More sharing options...
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