Jester009 Posted April 12, 2008 Share Posted April 12, 2008 (edited) Hi guys, I'm trying to call "ContinueLoop" by a button. But I can't get it working. I have tried my best but it doesn't seem to work. Sample code is posted. Any help is deeply appreciated... expandcollapse popup#include <GUIConstants.au3> #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 297, 197, 193, 125) $Label1 = GUICtrlCreateLabel("Number", 64, 40, 149, 33, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Button1", 56, 96, 75, 25, 0) $Button2 = GUICtrlCreateButton("Button2", 168, 96, 75, 25, 0) GUICtrlSetOnEvent(-1, "breakLoop") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 GUISetOnEvent($GUI_EVENT_CLOSE, "closeEvent") $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 incNum() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func incNum() Opt("GUIOnEventMode",1) For $i = 0 To 20 GUICtrlSetData($Label1, $i) Sleep(10000) Next Opt("GUIOnEventMode",0) MsgBox(0, "Status", "Done") EndFunc Func closeEvent() Exit EndFunc Func breakLoop() While 1 ContinueLoop 2 WEnd EndFunc Thanks in advance Jester009 Edited April 12, 2008 by Jester009 Link to comment Share on other sites More sharing options...
d4rk Posted April 12, 2008 Share Posted April 12, 2008 you can't use continueloop outside the loop [quote]Don't expect for a perfect life ... Expect a least troubles ones[/quote]Contact me : ass@kiss.toWhat I Have Done :Favorites Manager Mangage your favorite's folder, that's coolPC Waker For those who want to save stickersWebScipts Supporter For those who've just started with Web and WebScriptsTemporary Looker Simple but powerful to manage your Temporary folder, you know what you downloaded[UDF] _NumberFormat() Better performance on number display[UDF] _DirGet() What a folder contain [how many (hidden,normal,...) files], with one line of code[UDF] _IsPressEs() Just like _IsPress() but for a group of keys Link to comment Share on other sites More sharing options...
Jester009 Posted April 12, 2008 Author Share Posted April 12, 2008 you can't use continueloop outside the loopYes, That's why I used ContinueLoop 2 (two levels) Bur seems that does not work.Any other method to achieve what I'm trying?? Link to comment Share on other sites More sharing options...
MHz Posted April 12, 2008 Share Posted April 12, 2008 Use a variable to flag a ContinueLoop or ExitLoop. expandcollapse popup#include <GUIConstants.au3> Global $breakloop #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 297, 197, 193, 125) $Label1 = GUICtrlCreateLabel("Number", 64, 40, 149, 33, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Start", 26, 96, 75, 25, 0) $Button2 = GUICtrlCreateButton("BreakLoop", 138, 96, 75, 25, 0) GUICtrlSetOnEvent(-1, "_breakLoop") $Button2 = GUICtrlCreateButton("ContinueLoop", 218, 96, 75, 25, 0) GUICtrlSetOnEvent(-1, "_continueloop") $label2 = GUICtrlCreateLabel("", 20, 150, 160, 30) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 GUISetOnEvent($GUI_EVENT_CLOSE, "closeEvent") $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 incNum() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func incNum() Opt("GUIOnEventMode",1) For $i = 0 To 20 If $breakloop = 1 Then $breakloop = 0 GUICtrlSetData($label2, "") ContinueLoop ElseIf $breakloop = 2 Then $breakloop = 0 GUICtrlSetData($label2, "") ExitLoop EndIf GUICtrlSetData($Label1, $i) Sleep(5000) Next Opt("GUIOnEventMode",0) MsgBox(0, "Status", "Done") EndFunc Func closeEvent() Exit EndFunc Func _continueLoop() $breakloop = 1 GUICtrlSetData($label2, "Continue Loop") EndFunc Func _breakLoop() $breakloop = 2 GUICtrlSetData($label2, "Break out of Loop") EndFunc Link to comment Share on other sites More sharing options...
Jester009 Posted April 12, 2008 Author Share Posted April 12, 2008 Thanks MHz, Your code seems to do the trick. But it does not save me the sleep time that I have put there. What I want is a method to skip the Sleep(10000) part when I want to. (Sometimes I want to wait the whole 10 seconds, sometimes I don't want) Any method?? Link to comment Share on other sites More sharing options...
MHz Posted April 12, 2008 Share Posted April 12, 2008 (edited) OK, then change the sleep pattern with another For loop conditionally checking for setting of $breakloop expandcollapse popup#include <GUIConstants.au3> Global $breakloop #Region ### START Koda GUI section ### Form= $Form1 = GUICreate("Form1", 297, 197, 193, 125) $Label1 = GUICtrlCreateLabel("Number", 64, 40, 149, 33, $SS_CENTER) GUICtrlSetFont(-1, 18, 400, 0, "MS Sans Serif") $Button1 = GUICtrlCreateButton("Start", 26, 96, 75, 25, 0) $Button2 = GUICtrlCreateButton("BreakLoop", 138, 96, 75, 25, 0) GUICtrlSetOnEvent(-1, "_breakLoop") $Button2 = GUICtrlCreateButton("ContinueLoop", 218, 96, 75, 25, 0) GUICtrlSetOnEvent(-1, "_continueloop") $label2 = GUICtrlCreateLabel("", 20, 150, 160, 30) GUICtrlSetFont(-1, 16, 400, 0, "MS Sans Serif") GUISetState(@SW_SHOW) #EndRegion ### END Koda GUI section ### While 1 GUISetOnEvent($GUI_EVENT_CLOSE, "closeEvent") $nMsg = GUIGetMsg() Switch $nMsg Case $Button1 incNum() Case $GUI_EVENT_CLOSE Exit EndSwitch WEnd Func incNum() Opt("GUIOnEventMode",1) For $i = 0 To 20 If $breakloop = 1 Then $breakloop = 0 GUICtrlSetData($label2, "") ContinueLoop ElseIf $breakloop = 2 Then $breakloop = 0 GUICtrlSetData($label2, "") ExitLoop EndIf GUICtrlSetData($Label1, $i) ; Conditinal sleep For $j = 1 To 40 If $breakloop Then ExitLoop EndIf Sleep(250) Next Next Opt("GUIOnEventMode",0) MsgBox(0, "Status", "Done") EndFunc Func closeEvent() Exit EndFunc Func _continueLoop() $breakloop = 1 GUICtrlSetData($label2, "Continue Loop") EndFunc Func _breakLoop() $breakloop = 2 GUICtrlSetData($label2, "Break out of Loop") EndFunc Edited April 12, 2008 by MHz Link to comment Share on other sites More sharing options...
Jester009 Posted April 12, 2008 Author Share Posted April 12, 2008 WOW. Thanks a lot MHz. It's really a nice move to put sleep inside another for loop. Solves my problem. Thanks again..... Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now