# loop

## Recommended Posts

I have two 2D arrays.
Array One is columns 0 to 5 (5 being blank) (data in 0 -4)
Number of rows is 30 (could be more)

Array Two is column 0 - 1 (data in both)
Number of rows is 120(could be more)
```;held the column reference constant since it will never change for comparisons

For \$i = 0 to UBound(\$aABC,1) -1
For \$x = 0 to UBound(\$aPay,1) -1
if StringCompare("\$aABC[\$i] [2}", "\$aPay [\$x] [0]", \$STR_NOCASESENSEBASIC)  Then
\$aABC [\$i] [5] =  \$apay [\$x] [1]

EndIf
Next
Next```

Objective is to after populating both arrays, to find a string in One (column 2) that is also in Two (column 0) (not case sensitive).
If there is a match in Two, take the string in Two (column 1) and put in in One (column 5)of same row of compared string.

Array One
col 0    col 1   col 2     col 3    col 4   col 5
xx       123      mike      4.5     x78     (blank)
cd       456     george   2.0     mno   (blank)

Array Two
col 0    col 1
fred     boat
bill      tent
mike   arrows
tom    ax

So after running the code "arrows" would show up in One (col 5) of row 0, since mike matched in both.

Here is what I have, but it is not working.  What should I be doing and WHY?
I'm thinking the inner loop would always have to start back at 0 whenever \$i changes for One, otherwise it might miss a match.

##### Share on other sites

Hi,

In autoit, strings are not evaluated.

So in your string compare function it will compare "\$aABC[\$i] [2}" and "\$aPay [\$x] [0]" as strings and not as vars.

Br, FireFox.

Edited by FireFox
##### Share on other sites

FireFox

OK, so i altered the code, IF   I understand you correctly.  Does it look right?  Shoot holes in what I did.  I'm new, so a lot I don't know.

```For \$i = 0 to UBound(\$aABC,1) -1
For \$x = 0 to UBound(\$aPay,1) -1

if \$aABC[\$i] [2] = \$aPay [\$x] [0] Then
\$aABC [\$i] [5] =  \$apay [\$x] [1]
EndIf

next
next ```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
×
• Create New...