Jump to content

Loops Bug


Dieuz
 Share

Recommended Posts

  • Developers

This code is really wrong in many many ways.

You are using CAll.

You are "calling" Restart from within itself .... will cause a stack overflow.

Run Tidy and it will tell you are missing an EndIF..

First try to make some code that works .. then add the nice to haves ... :P

SciTE4AutoIt3 Full installer Download page   - Beta files       Read before posting     How to post scriptsource   Forum etiquette  Forum Rules 
 
Live for the present,
Dream of the future,
Learn from the past.
  :)

Link to comment
Share on other sites

This code is really wrong in many many ways.

You are using CAll.

You are "calling" Restart from within itself .... will cause a stack overflow.

Run Tidy and it will tell you are missing an EndIF..

First try to make some code that works .. then add the nice to haves ... :P

Yes your right with the stack overflow. Ho yeah, and sorry if this code is wrong in many many many many ways but it's my first one and it's why I'm here to ask...How could I correct this stack overflow because I think it's the priority.

Run Tidy and it will tell you are missing an EndIF..

I just forgot it when I copied/pasted it on the forum. My script can run fine during 4-5 hours but it close due to this stack overflow. Edited by Dieuz
Link to comment
Share on other sites

How could I correct this stack overflow because I think it's the priority.

Rework your code so that functions are not calling themselves. Most likely you can use a loop to do what you desire.

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

Rework your code so that functions are not calling themselves. Most likely you can use a loop to do what you desire.

Do you think that those modificiations will correct the stack overflow? I changed the call for a While/Wend so the function is not calling itself.

;Hotkeys
HotKeySet("{HOME}", "Terminate") ;
HotKeySet("{F2}", "Start") ; 
HotKeySet("{F4}", "Pause") ; 

;Variables

Global $Paused
$ColorAttack = Pixelgetcolor(837,464)
$ColorVictory = Pixelgetcolor(402,169)
$Color5wins = Pixelgetcolor(595,387)
$Trophyswon = 0
$ColorBug = Pixelgetcolor(840,467)



While 1
    sleep(100)
Wend

Func Start()    ; happen only one time

;Stuff here

Restart()
EndFunc

Func Restart()
While   
;Stuff here

;5 WINS
If 


Else


;stuff here


EndIf
Wend
EndFunc


Func Pause()

;stuff here
    
EndFunc

Func Terminate()
  Exit(0)
  EndFunc

I incorporated the winner function in the Restart function.

Edited by Dieuz
Link to comment
Share on other sites

Do you think that those modificiations will correct the stack overflow?

:P Yes, I do.

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...