## Recommended Posts

I made a script in which ended up with alot of numbers in which I will refer to as \$numbers, and I have no idea how to make a "list" or an "array" for these numbers. \$numbers are then to divide \$MainNumb. This divided number is then to compare itself equal to \$const. The problem I am having is what command to use for the list or array, could I have some help?

##### Share on other sites

And is there a way to make a variable be 1 +-0,2, and nothing specific?

##### Share on other sites

The help file has a great section on arrays.  In the meantime, probably a good idea if you could post the code you have using the code tags <> that way folks can get a better sense of where you are getting stuck and what you have tried so far.

Build your own poker game with AutoIt: pokerlogic.au3 | Learn To Program Using FREE Tools with AutoIt

##### Share on other sites

As mentioned, there are great tutorials in the help file on using arrays, have you read through them and tried the examples? If you produce some code, or even a more detailed explanation of what you're trying to accomplish, we can probably do more to assist.

√-1 2^3 ∑ π, and it was delicious!

##### Share on other sites
```#include <ImageSearch.au3>
#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")
\$A1 = 0
\$A2 = 0
\$A3 = 0
\$A4 = 0
\$A5 = 0
\$B1 = 0
\$B2 = 0
\$B3 = 0
\$B4 = 0
\$B5 = 0
\$C1 = 0
\$C2 = 0
\$C3 = 0
\$C4 = 0
\$C5 = 0
\$D1 = 0
\$D2 = 0
\$D3 = 0
\$D4 = 0
\$D5 = 0
\$E1 = 0
\$E2 = 0
\$E3 = 0
\$E4 = 0
\$E5 = 0
Local \$Numbers = [\$A1, \$A2, \$A3, \$A4, \$A5, \$B1, \$B2, \$B3, \$B4, \$B5, \$C1,\$C2, \$C3, \$C4, \$C5, \$D1, \$D2, \$D3, \$D4, \$D5, \$E1, \$E2, \$E3, \$E4, \$E5]
While \$loop <> 5
\$MainNumb = FFColorCount (0x000000, 0, True,655, 576, 697, 604)

\$A1 = FFColorCount (0x000000, 0, True, 550, 233, 600, 263)
\$A2 = FFColorCount (0x000000, 0, True, 550, 279, 600, 318)
\$A3 = FFColorCount (0x000000, 0, True, 550, 327, 600, 361)
\$A4 = FFColorCount (0x000000, 0, True, 550, 384, 600, 414)
\$A5 = FFColorCount (0x000000, 0, True, 550, 427, 600, 463)

\$B1 = FFColorCount (0x000000, 0, True, 600, 233, 650, 263)
\$B2 = FFColorCount (0x000000, 0, True, 600, 279, 650, 318)
\$B3 = FFColorCount (0x000000, 0, True, 600, 327, 650, 361)
\$B4 = FFColorCount (0x000000, 0, True, 600, 384, 650, 414)
\$B5 = FFColorCount (0x000000, 0, True, 600, 427, 650, 463)

\$C1 = FFColorCount (0x000000, 0, True, 650, 233, 700, 263)
\$C2 = FFColorCount (0x000000, 0, True, 650, 279, 700, 318)
\$C3 = FFColorCount (0x000000, 0, True, 650, 327, 700, 361)
\$C4 = FFColorCount (0x000000, 0, True, 650, 384, 700, 414)
\$C5 = FFColorCount (0x000000, 0, True, 650, 427, 700, 463)

\$D1 = FFColorCount (0x000000, 0, True, 700, 233, 750, 263)
\$D2 = FFColorCount (0x000000, 0, True, 700, 279, 750, 318)
\$D3 = FFColorCount (0x000000, 0, True, 700, 327, 750, 361)
\$D4 = FFColorCount (0x000000, 0, True, 700, 384, 750, 414)
\$D5 = FFColorCount (0x000000, 0, True, 700, 427, 750, 463)

\$E1 = FFColorCount (0x000000, 0, True, 750, 233, 800, 263)
\$E2 = FFColorCount (0x000000, 0, True, 750, 279, 800, 318)
\$E3 = FFColorCount (0x000000, 0, True, 750, 327, 800, 361)
\$E4 = FFColorCount (0x000000, 0, True, 750, 384, 800, 414)
\$E5 = FFColorCount (0x000000, 0, True, 750, 427, 800, 463)

\$difference = \$MainNumb/\$Numbers
MsgBox(0, "test", \$difference)
Exit
If \$difference == 317/167 Then
exit
EndIf
WEnd

Func MyExit ()
Exit
EndFunc```

Here's the code, sorry for the mess, but here you can see what I am trying to do. I would not care too much about what the numbers are or how I got them, but the problem is within making the array and making it compare with a constant number. I don't know how I would use an array in this situation, and I would be very happy if someone could tell me if this is the correct use for it, or how to improve on it. I would appreciate if you commented on the whole code, but focus on the main issue as the code does run until the array problems starts to pop up.

##### Share on other sites

You're not modifying the \$Numbers array during your While loop so each item will remain 0, in fact you don't actually need to place the variables into the array since you can just use the array variable example: \$Number <-> \$Number.

I don't have the ImageSearch or FastFind UDFs so what do you thing \$Numbers should equal?  I can only assume \$MainNumb is a number, so what are you expecting with \$MainNumber/\$Numbers?  Are you expecting to compare the last item in the array or ??

##### Share on other sites

I think you mean something like this

```;#include <ImageSearch.au3>
;#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")

Local \$aNumbers
;With all zeros the same thing would be.. ;\$aNumbers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0]

;You could also use enum to have named indices
#cs
Local Enum \$eA1= 0, \$eA2, \$eA3 \$eA4, \$eA5, \$eB1, \$eB2........
;\$aNumbers is same as \$aNumbers[\$eA1]
;\$aNumbers is same as \$aNumbers[\$eB2]
#ce
Local \$iAvg, \$iDiff

For \$iLoop = 0 To 5
\$MainNumb = FFColorCount(0x000000, 0, True, 655, 576, 697, 604)

\$aNumbers = FFColorCount(0x000000, 0, True, 550, 233, 600, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 279, 600, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 327, 600, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 384, 600, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 427, 600, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 600, 233, 650, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 279, 650, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 327, 650, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 384, 650, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 427, 650, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 650, 233, 700, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 279, 700, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 327, 700, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 384, 700, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 427, 700, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 700, 233, 750, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 279, 750, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 327, 750, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 384, 750, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 427, 750, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 750, 233, 800, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 279, 800, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 327, 800, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 384, 800, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 427, 800, 463)

For \$i = 0 To UBound(\$aNumbers) - 1 ; arrays are zero based
\$iAvg += \$aNumbers[\$i] ;Have to access each individual item in an array
Next

\$iAvg /= (UBound(\$aNumbers))
\$iDiff = \$MainNumb / \$iAvg
MsgBox(0, "test", \$MainNumb & " / " & \$iAvg & " = " & \$iDiff)

If \$iDiff == 317 / 167 Then
MyExit()
EndIf
Next

;Just a dummy function to test with
Func FFColorCount(\$a, \$b, \$c, \$d, \$e, \$f, \$g)
Local Static \$x = 1000
\$x -= 25
Return \$x
EndFunc   ;==>FFColorCount

Func MyExit()
Exit
EndFunc   ;==>MyExit```

##### Share on other sites
8 hours ago, Subz said:

I don't have the ImageSearch or FastFind UDFs so what do you thing \$Numbers should equal?  I can only assume \$MainNumb is a number, so what are you expecting with \$MainNumber/\$Numbers?  Are you expecting to compare the last item in the array or ??

\$MainNumb is a number in which counts the amounts of pixels of a certain color (black int this case) on a part of my monitor, \$Numbers is then the array in which contains a list of values, the \$A(-E)1(-5) numbers. The \$A(-E)1(-5) numbers contains the amount of pixels in the same color of \$MainNumb. The \$Numbers and \$MainNumb have a chance to be the same picture, but they are in a different size, therefore I have a constant \$difference. so if \$MainNumb/\$Numbers == \$difference, then it would mean that it has the same picture.

##### Share on other sites
7 hours ago, Bilgus said:

I think you mean something like this

```;#include <ImageSearch.au3>
;#include "FastFind.au3"
#include <GDIPlus.au3>
#include <Array.au3>
HotKeySet("q", "MyExit")

Local \$aNumbers
;With all zeros the same thing would be.. ;\$aNumbers = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 , 0, 0, 0, 0, 0, 0, 0, 0]

;You could also use enum to have named indices
#cs
Local Enum \$eA1= 0, \$eA2, \$eA3 \$eA4, \$eA5, \$eB1, \$eB2........
;\$aNumbers is same as \$aNumbers[\$eA1]
;\$aNumbers is same as \$aNumbers[\$eB2]
#ce
Local \$iAvg, \$iDiff

For \$iLoop = 0 To 5
\$MainNumb = FFColorCount(0x000000, 0, True, 655, 576, 697, 604)

\$aNumbers = FFColorCount(0x000000, 0, True, 550, 233, 600, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 279, 600, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 327, 600, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 384, 600, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 550, 427, 600, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 600, 233, 650, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 279, 650, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 327, 650, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 384, 650, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 600, 427, 650, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 650, 233, 700, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 279, 700, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 327, 700, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 384, 700, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 650, 427, 700, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 700, 233, 750, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 279, 750, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 327, 750, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 384, 750, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 700, 427, 750, 463)

\$aNumbers = FFColorCount(0x000000, 0, True, 750, 233, 800, 263)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 279, 800, 318)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 327, 800, 361)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 384, 800, 414)
\$aNumbers = FFColorCount(0x000000, 0, True, 750, 427, 800, 463)

For \$i = 0 To UBound(\$aNumbers) - 1 ; arrays are zero based
\$iAvg += \$aNumbers[\$i] ;Have to access each individual item in an array
Next

\$iAvg /= (UBound(\$aNumbers))
\$iDiff = \$MainNumb / \$iAvg
MsgBox(0, "test", \$MainNumb & " / " & \$iAvg & " = " & \$iDiff)

If \$iDiff == 317 / 167 Then
MyExit()
EndIf
Next

;Just a dummy function to test with
Func FFColorCount(\$a, \$b, \$c, \$d, \$e, \$f, \$g)
Local Static \$x = 1000
\$x -= 25
Return \$x
EndFunc   ;==>FFColorCount

Func MyExit()
Exit
EndFunc   ;==>MyExit```

That is exactly what I was looking to do, thanks!

## Create an account

Register a new account

×

• Wiki

• Back

• #### Beta

• Git
• FAQ
• Our Picks
×
• Create New...