# Nested Array Problem in Beta

## Recommended Posts

The code inside the "For i\$..." runs fine without the outer loop. As soon as I place the "For i\$..." code in place, SciTE throws the error "Array variable has incorrect number of subscripts or subscript dimension range exceeded.:" The only difference is the For...Next? Can someone help me with this?

```\$startCol = 0
\$startRow = 0
\$c=0
\$r=0
\$i = 0
For \$i = 1 to 10
If \$aArray[1][\$startCol+5] <> " " Then
For \$d = 1 to 10
If \$aArray[\$startRow + 2][\$startCol+5] = "Yes" Then
\$bArray[\$r][\$c] =  \$aArray[1][\$startCol+5]
\$bArray[\$r][\$c+1] = \$aArray[\$startRow + 2][4] ;get the Drive Letter
\$bArray[\$r][\$c+2] = \$aArray[\$startRow + 2][2] ;then get the Share Name
\$r=\$r+1
\$c=0
EndIf
\$StartRow=\$StartRow+1
Next
EndIf
\$startCol=\$startCol+1
Next```
Edited by swicks

##### Share on other sites

Make sure you also declare \$aArray as a multidimensional array.

##### Share on other sites

Both arrays are dim'd as [12][15] arrays and the snippet works fine without the outer loop!

##### Share on other sites

Did you try Diming \$i = 1? Sometimes things like that cause problems,sometimes they don't.

##### Share on other sites

Yes, no joy :-(

Also tried a "Do" loop. Seems this may be a problem. All these statements can be nested and the logic is only four deep.

##### Share on other sites

Both arrays are dim'd as [12][15] arrays and the snippet works fine without the outer loop!

In your code \$r will reach 100 thus exceeding maximum 11 for your arrays first dimention

"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the universe trying to build bigger and better idiots. So far, the universe is winning."- Rick Cook

##### Share on other sites

Good catch Bowmore, would have crossed this bridge later on \$r.

But the snippet that erroring was:

"If \$aArray[\$startRow + 2][\$startCol+5] = "Yes""

Found the error in not resetting the \$startRow to 0 after the inner loop.

Thanks very much for getting me started in the right direction!

## Create an account

Register a new account