Sign in to follow this  
Followers 0
joeyg37

need help

6 posts in this topic

well im new and i dont know much about this i think it got it mostly rite but i get an error and need to fix it i cant figure it out

What im trying to do it loop those 2 things untill

MY ERROR

: ==> "While" statement has no matching "Wend" statement.:
func CheckRestart()

HotKeySet("{F5}" ,"start")
HotKeySet("{F6}" ,"stop")
HotKeySet("{F7}" ,"_exit")

Global $on = False

func start()
    $on = True
EndFunc

func stop()
    $on = False
EndFunc

func _exit()
    Exit
EndFunc

while 1=1
    sleep(30)
    While $on = True
        CheckRestart()
    WEnd


func CheckRestart()
while 1=1
            
$coord = PixelSearch( 326, 665, 364, 704, 0x00FF00 )
If Not @error Then
MouseClick("left", 344, 679, 2)  
  Sleep(500)
  MouseClick("left", 126, 680, 2) 
  func progress()
endif
wend
EndFunc


    func progress()
        while 1=1
            
$coord = PixelSearch( 174, 547, 174, 547, 0x25DF32 )
If Not @error Then
  Send(4)
  Sleep(1500)
  Send(5)
  sleep(1500)
  Send(6)
  sleep(1500)
Else
    Send(1)
  Sleep(1500)
  Send(2)
  sleep(1500)
  Send(3)
  sleep(1500)
  CheckRestart()
EndIf
WEnd
EndFunc

Share this post


Link to post
Share on other sites



#2 ·  Posted (edited)

The Wend here matches the second While. You need to add another one after it to match the first one.

while 1=1
             sleep(30)
             While $on = True
                 CheckRestart()
             WEnd
You can't declare a function within another function. It looks like you're trying to call the progress() function, so change "func progress()" to "progress()"

<span class="postcolor">func CheckRestart()
     while 1=1
                 
     $coord = PixelSearch( 326, 665, 364, 704, 0x00FF00 )
     If Not @error Then
     MouseClick("left", 344, 679, 2)  
       Sleep(500)
       MouseClick("left", 126, 680, 2) 
       func progress()
     endif
     wend
     EndFunc</span>
Make those two changes and you'll be able to compile, but there are other flaws you need to consider.

The While loop in the progress() function will never end since there's no ExitLoop or Return.

CheckRestart() and progress() both call each other, so you may run into recursion errors as the functions call each other continuously.

Based on these observations, it sounds like the best option is to change the CheckRestart() call within progress() to either ExitLoop or Return.

Edited by Skruge

[font="Tahoma"]"Tougher than the toughies and smarter than the smarties"[/font]

Share this post


Link to post
Share on other sites

The Wend here matches the second While. You need to add another one after it to match the first one.You can't declare a function within another function. It looks like you're trying to call the progress() function, so change "func progress()" to "progress()"

Make those two changes and you'll be able to compile, but there are other flaws you need to consider.

The While loop in the progress() function will never end since there's no ExitLoop or Return.

CheckRestart() and progress() both call each other, so you may run into recursion errors as the functions call each other continuously.

Based on these observations, it sounds like the best option is to change the CheckRestart() call within progress() to either ExitLoop or Return.

im not sure how to add the call, return or exitloop. im really new to autoit i dont know much at all lol

Share this post


Link to post
Share on other sites

im not sure how to add the call, return or exitloop. im really new to autoit i dont know much at all lol

Read the help file and take a programming 101 class.

Share this post


Link to post
Share on other sites

#5 ·  Posted (edited)

Global $on = False

Func start()
    $on = True
EndFunc

Func stop()
    $on = False
EndFunc

While 1 = 1
    Sleep(30)
    While $on = True
        $coord = PixelSearch(326, 665, 364, 704, 0x00FF00)
        If Not @error Then
            MouseClick("left", 344, 679, 2)
            Sleep(500)
            MouseClick("left", 126, 680, 2)
            progress()
        EndIf
    WEnd
WEnd

Func progress()
    While 1 = 1
        $coord = PixelSearch(174, 547, 174, 547, 0x25DF32)
        If Not @error Then
            Send(4)
            Sleep(1500)
            Send(5)
            Sleep(1500)
            Send(6)
            Sleep(1500)
        Else
            Send(1)
            Sleep(1500)
            Send(2)
            Sleep(1500)
            Send(3)
            Sleep(1500)
            ExitLoop
        EndIf
    WEnd
EndFunc


Func OnAutoItExit()
    Exit
EndFunc

I didn't check the syntax... but it looks right... What you had is Grade A terrible... No offense! Your new... When I first started, I was calling Functions from within functions in loops as well, as a matter of fact I recently posted an example script like that, I knew it was terrible, but it was a quick fix for a problem, and I was giving up the project... but it is by ANY-MEANS a terrible bad idea...

Edited by BinaryBrother

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