Jump to content

Array problem


Recommended Posts

hi, i am having a problem and i don't have a clue how this happens... It chrashes my .exe.

the error message is :

"Error: Subscript used with non-array variable"

the following code is the code i am using...

----------------------------------------------------------

"interface stuff"

inicio ()

Func inicio ()

While 1

$msg = GUIGetMsg()

Select

Case $msg = $GUI_EVENT_CLOSE

Exit

EndSelect

WEnd

EndFunc

Func charcheck ()

Dim $var1[2]

Dim $var2[2]

Dim $var3[2]

Dim $var4[2]

sleep(200)

Send("v")

sleep(1000)

$var1 = PixelSearch( 400, 33, 415, 33, 0xFFFFFF, 100 )

$var2 = PixelSearch( 415, 33, 432, 33, 0xFFFFFF, 100 )

$var3 = PixelSearch( 432, 33, 490, 33, 0xFFFFFF, 100 )

$var4 = PixelSearch( 490, 33, 520, 33, 0xFFFFFF, 100 )

sleep(1000)

If Not @error Then

If $var4[0]=493 Then

sleep(200)

Send("{LEFT down}")

Sleep(1050)

Send("{LEFT UP}")

sleep(500)

Send("oo{SPACE}")

sleep(8000)

Send("r")

inicio ()

EndIf

If $var1[0]=402 Then

sleep(200)

Send("{LEFT down}")

Sleep(1050)

Send("{LEFT UP}")

sleep(500)

Send("oo{SPACE}")

sleep(12000)

Send("r")

inicio ()

EndIf

If $var4[0]=491 Then

sleep(200)

Send("{RIGHT down}")

Sleep(250)

Send("{RIGHT UP}")

sleep(500)

Send("oo{SPACE}")

sleep(8500)

Send("r")

inicio ()

EndIf

If ($var3[0]=437) AND ($var4[0]=495) Then

sleep(200)

Send("{RIGHT down}")

Sleep(250)

Send("{RIGHT UP}")

sleep(500)

Send("oo{SPACE}")

sleep(9000)

Send("r")

inicio ()

EndIf

If $var4[0]=490 Then

sleep(200)

Send("xr")

sleep(200)

inicio ()

EndIf

If $var4[0]=494 Then

sleep(200)

Send("{SPACE}")

sleep(2000)

Send("xr")

sleep(100)

inicio ()

EndIf

EndIf

EndFunc

-------------------------------------------

Link to comment
Share on other sites

Does this happen when the script is not compiled?

I would recommend putting an error check after each pixel search, something like this;

If @error Then
    MsgBox(0, "var1", "error in pixelsearch")
    Return
EndIf

If the error happens uncompiled then Scite will give you a better indication of where the error is.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
Link to comment
Share on other sites

If PixelSearch() fails, it does not return an array. So you need to test that before using the results.

:)

Edit: someone, we don't know who, beat me to it... :)

Edited by PsaltyDS
Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Does this happen when the script is not compiled?

I would recommend putting an error check after each pixel search, something like this;

If @error Then
    MsgBox(0, "var1", "error in pixelsearch")
    Return
EndIf

If the error happens uncompiled then Scite will give you a better indication of where the error is.

----------------------------

the error is when it makes the --» if $var4[0]="something"

Link to comment
Share on other sites

----------------------------

the error is when it makes the --» if $var4[0]="something"

I should have pointed this out before, in these lines;

$var4 = PixelSearch( 490, 33, 520, 33, 0xFFFFFF, 100 )
sleep(1000)

If Not @error Then

Your not checking the error of the PixelSearch but whether there was an error with Sleep. Add what I said under each line of pixel search (even though the error is probaly with the 4th just do it for all).

That will probably confirm that your 4th PixelSearch is not finding the color.

While ProcessExists('Andrews bad day.exe')
	BlockInput(1)
	SoundPlay('Music.wav')
	SoundSetWaveVolume('Louder')
WEnd
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...