# having trouble solving this error

## Recommended Posts

Error:

\$chairpix1 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi1x, \$tablepos2[1] + \$chairy + \$chairpi1y)

\$chairpix1 = PixelGetColor(\$tablepox2^ ERROR

Error: Subscript used with non-Array variable.

```jointable("table jojojo 123")

Func jointable(\$movethistable1)
sleep(2000)
dim \$chairpix1, \$chairpix2, \$chairpix3, \$tablepos2

\$movethistable2 = \$movethistable1

;dim \$tablepos2
\$tablepos2 = WinGetPos(\$movethistable2)
sleep(300)
\$tablepos2 = WinGetPos(\$movethistable2)

\$chaircount = 0

\$chairpi1x = 10
\$chairpi1y = 13
\$chairpi2x = 29
\$chairpi2y = 10
\$chairpi3x = 57
\$chairpi3y = 18

\$k = 1
For \$k = 1 to 10

if \$k = 1 Then
\$chairx = 499
\$chairy = 40
EndIf
if \$k = 2 Then
\$chairx = 686
\$chairy = 123
EndIf
if \$k = 3 Then
\$chairx = 716
\$chairy = 245
EndIf
if \$k = 4 Then
\$chairx = 614
\$chairy = 374
EndIf
if \$k = 5 Then
\$chairx = 455
\$chairy = 390
EndIf
if \$k = 6 Then
\$chairx = 271
\$chairy = 390
EndIf
if \$k = 7 Then
\$chairx = 115
\$chairy = 375
EndIf
if \$k = 8 Then
\$chairx = 7
\$chairy = 247
EndIf
if \$k = 9 Then
\$chairx = 32
\$chairy = 122
EndIf
if \$k = 10 Then
\$chairx = 221
\$chairy = 40
EndIf

\$chairpix1 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi1x, \$tablepos2[1] + \$chairy + \$chairpi1y)
\$chairpix2 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi2x, \$tablepos2[1] + \$chairy + \$chairpi2y)
\$chairpix3 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi3x, \$tablepos2[1] + \$chairy + \$chairpi3y)

if \$chairpix1 = 6639140 and \$chairpix2 = 10520401 and \$chairpix3 = 10387264 Then
\$chair[\$k] = "open"
\$chaircount = \$chaircount + 1
Else
\$chair[\$k] = "closed"
EndIf

Next

EndFunc```

maybe its bad formating or something? i just cant stop this error message from comming up. it doesnt come up every time, just one in every 3-4 times and i cant pin point what the problem is. can anyone help me, thank you

##### Share on other sites

You get this error because the Window with the label is not found.

WinGetPos returns 0 and NOT an array. End @error is set to 1.

(See help file fro WinGetPos)

Try this example (beta needed!).

I took the liberty to change your code to make it more readable.

```jointable("table jojojo 123")

Func jointable(\$movethistable1)
sleep(2000)
dim \$chairpix1, \$chairpix2, \$chairpix3, \$tablepos2

\$movethistable2 = \$movethistable1

;dim \$tablepos2
\$tablepos2 = WinGetPos(\$movethistable2)
sleep(300)
\$tablepos2 = WinGetPos(\$movethistable2)
; Check if window is detected, if not then return 0
If @error Then
Return(0)
EndIf

\$chaircount = 0

\$chairpi1x = 10
\$chairpi1y = 13
\$chairpi2x = 29
\$chairpi2y = 10
\$chairpi3x = 57
\$chairpi3y = 18

\$k = 1
For \$k = 1 to 10

Switch \$k

Case 1
\$chairx = 499
\$chairy = 40
Case 2
\$chairx = 686
\$chairy = 123
Case 3
\$chairx = 716
\$chairy = 245
Case 4
\$chairx = 614
\$chairy = 374
Case 5
\$chairx = 455
\$chairy = 390
Case 6
\$chairx = 271
\$chairy = 390
Case 7
\$chairx = 115
\$chairy = 375
Case 8
\$chairx = 7
\$chairy = 247
Case 9
\$chairx = 32
\$chairy = 122
Case 10
\$chairx = 221
\$chairy = 40
EndSwitch

\$chairpix1 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi1x, \$tablepos2[1] + \$chairy + \$chairpi1y)
\$chairpix2 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi2x, \$tablepos2[1] + \$chairy + \$chairpi2y)
\$chairpix3 = PixelGetColor(\$tablepos2[0] + \$chairx + \$chairpi3x, \$tablepos2[1] + \$chairy + \$chairpi3y)

if \$chairpix1 = 6639140 and \$chairpix2 = 10520401 and \$chairpix3 = 10387264 Then
\$chair[\$k] = "open"
\$chaircount = \$chaircount + 1
Else
\$chair[\$k] = "closed"
EndIf

Next

Return 1
EndFunc```

## Create an account

Register a new account

• ### Recently Browsing   0 members

×

• Wiki

• Back

• #### Beta

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