I have a (non-global) function that scans the harddrive based on some criteria. The function starts a folder loop that may take up to 15-20 minutes.
The scanner have a GUI and the function/loop is started with a button called "Scan".
I have tried to add a button called "Stop" that is supposed to break the loop, but so far I haven't found a proper way to do so. Any suggestions?
For now I made it so that the "Stop" button FileAppend a text file in a cachefolder called "STOP". Then I added a FileExist in each loop that breaks the loop and delete the file if it exist.
Adding a "Stop" button to a function
Re: Adding a "Stop" button to a function
You could as well check a global variable in the loop. The variable gets changed with the scan and stop button. This way the loop breaks at the next iteration.
ciao
toralf
toralf
Re: Adding a "Stop" button to a function
Creating a file seems overkill, I would just set a flag, and check that in your loop
Code: Select all
Gui, Add, Button,, Start
Gui, Add, Button,, Stop
Gui, Show
return
ButtonStart:
Loop
{
tooltip, looping
if(stop)
{
ToolTip
return
}
}
return
ButtonStop:
stop := true
return
I have no idea what I'm doing.