Digisoul Posted November 7, 2008 Share Posted November 7, 2008 Hello guys,Is there any way to exit from while loop inside any function trough a contol button ?e.g :i have a 1 button in GUI to call "search function"the "search function" use while 1 loop.now i want to stop that loop from Pause button.So how can i complete this task?i tried it but , when i call "search funtion" im not able to exit from the loop until the loops end.Thanks in Advance for your help. 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
youknowwho4eva Posted November 7, 2008 Share Posted November 7, 2008 Supply some script and it will be easier to help. Giggity Link to comment Share on other sites More sharing options...
Digisoul Posted November 7, 2008 Author Share Posted November 7, 2008 (edited) Supply some script and it will be easier to help. i know this example in GUI but thats a short example of my current project. expandcollapse popupglobal $g = 0 $s_window= GUICreate("Search window", 550, 400, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_WINDOWEDGE)) GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") $crnt_file = GUICtrlCreateLabel("", 48, 104, 489, 33,$SS_LEFTNOWORDWRAP) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT $start = GUICtrlCreateButton("start", 425, 370, 54, 25) GUISetOnEvent($start, "start_sch") $pause = GUICtrlCreateButton("Pause", 425, 370, 54, 25, BitOR($BS_FLAT,$BS_BITMAP)) GUISetOnEvent($start, "pause_sch") while 1 sleep(1000) wend Func start_sch() Search("D:\","*.*") EndFunc Func pause_sch() $g = 1 Endfunc Func Search($current,$toFind) If $g <> 1 Then If StringRight($current,1) = "\" then $current = StringTrimRight($current,1) Local $search = FileFindFirstFile($current & "\*.*") While 1 Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then GUICtrlSetData($crnt_file,$current& "\" &$file) Sleep(10) ConsoleWrite(@CRLF&"+>"&$i&"File Name "&$current& "\" &$file) IF $file = $toFind then Msgbox(0,"File found", $current & "\" & $file) EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then Search($current & "\" & $file, $toFind) EndIf WEnd FileClose($search) EndIf EndFunc Edited November 7, 2008 by Digisoul 73 108 111 118 101 65 117 116 111 105 116 Link to comment Share on other sites More sharing options...
senthor Posted November 7, 2008 Share Posted November 7, 2008 Try this: expandcollapse popupglobal $g = 0 global $bStop = 0 $s_window= GUICreate("Search window", 550, 400, -1, -1, -1, BitOR($WS_EX_APPWINDOW, $WS_EX_WINDOWEDGE)) GUISetOnEvent($GUI_EVENT_CLOSE, "on_exit") $crnt_file = GUICtrlCreateLabel("", 48, 104, 489, 33,$SS_LEFTNOWORDWRAP) GUICtrlSetBkColor(-1, $GUI_BKCOLOR_TRANSPARENT $start = GUICtrlCreateButton("start", 425, 370, 54, 25) GUISetOnEvent($start, "start_sch") $pause = GUICtrlCreateButton("Pause", 425, 370, 54, 25, BitOR($BS_FLAT,$BS_BITMAP)) GUISetOnEvent($start, "pause_sch") while 1 sleep(1000) wend Func start_sch() Search("D:\","*.*") EndFunc Func pause_sch() $bStop = 1 $g = 1 Endfunc Func Search($current,$toFind) If $g <> 1 Then If StringRight($current,1) = "\" then $current = StringTrimRight($current,1) Local $search = FileFindFirstFile($current & "\*.*") While not $bStop Dim $file = FileFindNextFile($search) If @error Or StringLen($file) < 1 Then ExitLoop If Not StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then GUICtrlSetData($crnt_file,$current& "\" &$file) Sleep(10) ConsoleWrite(@CRLF&"+>"&$i&"File Name "&$current& "\" &$file) IF $file = $toFind then Msgbox(0,"File found", $current & "\" & $file) EndIf If StringInStr(FileGetAttrib($current & "\" & $file), "D") And ($file <> "." Or $file <> "..") Then Search($current & "\" & $file, $toFind) EndIf WEnd FileClose($search) EndIf EndFunc FileListToArray UDFMy tools 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