Jump to content

Nested for - inner for skipped

Recommended Posts


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)
    For $count = 0 To UBound($content_array) - 1
                If $search_result<>0  Then
                    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]


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

Share this post

Link to post
Share on other sites

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]


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


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.