Sign in to follow this  
Followers 0
Stoex

loop

3 posts in this topic

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 this post


Link to post
Share on other sites



#2 ·  Posted (edited)

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

 

OS : Win XP SP2 (32 bits) / Win 7 SP1 (64 bits) / Win 8 (64 bits) | Autoit version: latest stable / beta.
Hardware : Intel(R) Core(TM) i5-2400 CPU @ 3.10Ghz / 8 GiB RAM DDR3.

My UDFs : Skype UDF | TrayIconEx UDF | GUI Panel UDF | Excel XML UDF | Is_Pressed_UDF

My Projects : YouTube Multi-downloader | FTP Easy-UP | Lock'n | WinKill | AVICapture | Skype TM | Tap Maker | ShellNew | Scriptner | Const Replacer | FT_Pocket | Chrome theme maker

My Examples : Capture toolIP Camera | Crosshair | Draw Captured Region | Picture Screensaver | Jscreenfix | Drivetemp | Picture viewer

My Snippets : Basic TCP | Systray_GetIconIndex | Intercept End task | Winpcap various | Advanced HotKeySet | Transparent Edit control

 

Share this post


Link to post
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 

  

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
Sign in to follow this  
Followers 0