Jump to content

Comparing arrays


KSagle
 Share

Recommended Posts

Hey,

I made a program which finds a number on the desktop based on colored pixels, and then makes a 2d array, with colored pixels represented by 1s.

I have a bunch of predefined 2d arrays, the same size, which represent all the possible numbers. I'd like to compare the one the program found to the predefined ones to find which number it is, but am having trouble.

Everytime it makes a comparison, it says it is true, whether it is or not. I really just need to know the syntax, and havnt been ablt to find it.

Any help is appreciated.

Thanks

Link to comment
Share on other sites

Thanks for the quick replies...

I did try that, but it doesn't seem to work.

Heres the code which finds the colored pixels and changes the values accordingly...

for $x = 0 to 4

for $y = 0 to 10

$colored = PixelSearch ( $x + $topx1, $y + $topy, $x + $topx1, $y + $topy, 0xFF0000 , 100 )

If Not @error Then

$Number[$x][$y] = 1

ElseIf

$coord = PixelSearch ( $x + $topx1, $y + $topy, $x + $topx1, $y + $topy, 0x000000 , 100 )

If Not @error Then

$Number[$x][$y] = 1

EndIf

Next

Next

I know that this works correctly, because I have a function which paints a visual representation, and it does match the number.

Then, I have 14 predefined arrays such as...

;Ace

Dim $A[5][14]

$A[0][0] = 0

$A[0][1] = 0

$A[0][2] = 0

$A[0][3] = 0

$A[0][4] = 0

$A[0][5] = 0

$A[0][6] = 0

$A[0][7] = 0

$A[0][8] = 0

$A[0][9] = 1

$A[0][10] = 0

$A[1][0] = 0

$A[1][1] = 0

$A[1][2] = 0

$A[1][3] = 0

$A[1][4] = 0

$A[1][5] = 1

$A[1][6] = 1

$A[1][7] = 1

$A[1][8] = 1

$A[1][9] = 1

$A[1][10] = 0

$A[2][0] = 0

$A[2][1] = 0

$A[2][2] = 1

$A[2][3] = 1

$A[2][4] = 1

$A[2][5] = 1

$A[2][6] = 1

$A[2][7] = 1

$A[2][8] = 0

$A[2][9] = 0

$A[2][10] = 0

$A[3][0] = 0

$A[3][1] = 0

$A[3][2] = 1

$A[3][3] = 1

$A[3][4] = 1

$A[3][5] = 1

$A[3][6] = 1

$A[3][7] = 1

$A[3][8] = 0

$A[3][9] = 0

$A[3][10] = 0

$A[4][0] = 0

$A[4][1] = 0

$A[4][2] = 0

$A[4][3] = 1

$A[4][4] = 1

$A[4][5] = 1

$A[4][6] = 1

$A[4][7] = 1

$A[4][8] = 1

$A[4][9] = 1

$A[4][10] = 0

Which represent the numbers. I'd like to compare the one found by the top code to the predefined ones to find out which is it.

Link to comment
Share on other sites

Did you try matching each element of the arrays to see which ones match and which don't? You already know which should and shouldn't match, so maybe that will help you determine the source of your problem.

IE Dev ToolbarMSDN: InternetExplorer ObjectMSDN: HTML/DHTML Reference Guide[quote]It is surprising what a man can do when he has to, and how little most men will do when they don't have to. - Walter Linn[/quote]--------------------[font="Franklin Gothic Medium"]Post a reproducer with less than 100 lines of code.[/font]
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...