Skrip Posted January 7, 2007 Share Posted January 7, 2007 (edited) expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <String.au3> Global $msgbo $stop = 0 $moveon = 0 $i = 0 $random1 = 0 $pause = 0 $Form1 = GUICreate("********", 574, 211, 193, 115) $Input1 = GUICtrlCreateInput("Type file address or click browse...", 112, 32, 433, 21) $Button1 = GUICtrlCreateButton("Browse", 24, 16, 81, 25, 0) $Button2 = GUICtrlCreateButton("Start", 24, 48, 81, 25, 0) $Label1 = GUICtrlCreateLabel("Number of Lines to ******:", 120, 56, 133, 17) $Input2 = GUICtrlCreateInput("1000", 256, 56, 57, 17) $Group1 = GUICtrlCreateGroup("*********", 184, 112, 177, 97) $Label2 = GUICtrlCreateLabel("Completed:", 200, 136, 160, 17) $Label3 = GUICtrlCreateLabel("Line: ", 200, 160, 160, 17) $Label4 = GUICtrlCreateLabel("Wrote: ", 200, 184, 160, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button3 = GUICtrlCreateButton("Stop *********", 376, 168, 91, 25, 0) ControlDisable("*********", "", $Button3) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file_browse = FileOpenDialog("Select a File", "", "All(*.*)", 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Please select a different file, or restart the program.") Else GUICtrlSetData($Input1, $file_browse) EndIf Case $Button2 ControlDisable("********", "", $Button1) ControlDisable("********", "", $Button2) ControlEnable("********", "", $Button3) $lines = GUICtrlRead($Input2) $file_get = GUICtrlRead($Input1) $random1 = Random(1, _FileCountLines($file_get), 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #003 at " & @error & @CRLF & "This Error most likey means that there was an error reading how many lines the file has." & @CRLF & "The program will continue, but other errors may occure.") EndIf If FileExists($file_get) Then $moveon = 1 Else $moveon = 0 EndIf If $moveon = 1 Then $file = FileOpen($file_get, 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #004 at" & @error) Exit EndIf GUICtrlSetData($Label2, "Completed: " & $i & " of " & $lines) GUICtrlSetData($Label3, "Line: " & $random1) Do _StopCheck(0) $i = $i + 1 $random1 = Random(1, _FileCountLines($file_get) + 1, 1) $random2 = Random(1, 50000, 1) ;************ If @error < 0 Then $msgbo = MsgBox(4, "Error - " & @error, "We have encountered an error while ****** the file. The program will be forced to exit." & @CRLF & "Erase file contents?") If $msgbo = 6 Then FileClose($file) $file = FileOpen($file_get, 2) MsgBox(0, "Complete", "Contents erased. Program exiting.") $i = 1000 Exit Else $i = 1000 Exit EndIf EndIf GUICtrlSetData($Label2, "Completed: " & $i & " of " & $lines) GUICtrlSetData($Label3, "Line: " & $random1) GUICtrlSetData($Label4, "Wrote: " & $random2) Until $i = $lines $i = 0 FileClose($file) MsgBox(0, "Complete", "******** Complete.") Sleep(10) Else MsgBox(48, "Error", "The selected file cannot be found. Please select a different file...") EndIf Case $Button3 _StopCheck(1) EndSwitch WEnd Func _StopCheck($stop) If $stop = 1 Then $i = $lines EndIf EndFunc Can somebody tell me why the stop button won't work? (Sorry, had to blank out some words... (*****)) Edited January 7, 2007 by Firestorm [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] Link to comment Share on other sites More sharing options...
BALA Posted January 7, 2007 Share Posted January 7, 2007 (edited) First of all, do the other buttons work? I think it may lie somewhere in how you did the Switch-EndSwitch I keep getting an error about it. Edited January 7, 2007 by BALA [font="Comic Sans MS"]BA-LA[/font]http://ba-la.110mb.comJoin my community, CLICK HEREAlternative links to my site:http://www.ba-la.tkhttp://www.ba-la.co.nrContact me if you would like to help with some of my projects: joeythepirate@gmail.com Link to comment Share on other sites More sharing options...
GaryFrost Posted January 7, 2007 Share Posted January 7, 2007 Suggest using OnEvent for the button to work during the loops. SciTE for AutoItDirections for Submitting Standard UDFs  Don't argue with an idiot; people watching may not be able to tell the difference.  Link to comment Share on other sites More sharing options...
Skrip Posted January 7, 2007 Author Share Posted January 7, 2007 First of all, do the other buttons work? I think it may lie somewhere in how you did the Switch-EndSwitch I keep getting an error about it. What error exactly? Suggest using OnEvent for the button to work during the loops. I can't figure this out...If I place the Opt near the top of the script, none on my buttons will work, and it won't close. So I placed it in the button ($button2) and then I have GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_StopCheck") within the loop, but nope. It's not working... expandcollapse popup#include <GUIConstants.au3> #include <File.au3> #include <String.au3> Global $msgbo $stop = 0 $moveon = 0 $i = 0 $random1 = 0 $pause = 0 $Form1 = GUICreate("*********", 574, 211, 193, 115) $Input1 = GUICtrlCreateInput("Type file address or click browse...", 112, 32, 433, 21) $Button1 = GUICtrlCreateButton("Browse", 24, 16, 81, 25, 0) $Button2 = GUICtrlCreateButton("Start***", 24, 48, 81, 25, 0) $Label1 = GUICtrlCreateLabel("Number of Lines to ******:", 120, 56, 133, 17) $Input2 = GUICtrlCreateInput("1000", 256, 56, 57, 17) $Group1 = GUICtrlCreateGroup("*********", 184, 112, 177, 97) $Label2 = GUICtrlCreateLabel("Completed:", 200, 136, 160, 17) $Label3 = GUICtrlCreateLabel("Line: ", 200, 160, 160, 17) $Label4 = GUICtrlCreateLabel("Wrote: ", 200, 184, 160, 17) GUICtrlCreateGroup("", -99, -99, 1, 1) $Button3 = GUICtrlCreateButton("Stop *********", 376, 168, 91, 25, 0) ControlDisable("Corruptor", "", $Button3) GUISetState(@SW_SHOW) While 1 $Msg = GUIGetMsg() Switch $Msg Case $GUI_EVENT_CLOSE Exit Case $Button1 $file_browse = FileOpenDialog("Select a File", "", "All(*.*)", 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Please select a different file, or restart the program.") Else GUICtrlSetData($Input1, $file_browse) EndIf Case $Button2 Opt("GUIOnEventMode", 1) ControlDisable("*********", "", $Button1) ControlDisable("*********", "", $Button2) ControlEnable("*********", "", $Button3) $lines = GUICtrlRead($Input2) $file_get = GUICtrlRead($Input1) $random1 = Random(1, _FileCountLines($file_get), 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #003 at " & @error & @CRLF & "This Error most likey means that there was an error reading how many lines the file has." & @CRLF & "The program will continue, but other errors may occure.") EndIf If FileExists($file_get) Then $moveon = 1 Else $moveon = 0 EndIf If $moveon = 1 Then $file = FileOpen($file_get, 1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #004 at" & @error) Exit EndIf GUICtrlSetData($Label2, "Completed: " & $i & " of " & $lines) GUICtrlSetData($Label3, "Line: " & $random1) Do GUISetOnEvent($GUI_EVENT_PRIMARYDOWN, "_StopCheck") $i = $i + 1 $random1 = Random(1, _FileCountLines($file_get) + 1, 1) $random2 = Random(1, 50000, 1) ;*************************** If @error < 0 Then $msgbo = MsgBox(4, "Error - " & @error, "We have encountered an error while ********* the file. The program will be forced to exit." & @CRLF & "Erase file contents?") If $msgbo = 6 Then FileClose($file) $file = FileOpen($file_get, 2) MsgBox(0, "Complete", "Contents erased. Program exiting.") $i = $lines Exit Else $i = $lines Exit EndIf EndIf GUICtrlSetData($Label2, "Completed: " & $i & " of " & $lines) GUICtrlSetData($Label3, "Line: " & $random1) GUICtrlSetData($Label4, "Wrote: " & $random2) Until $i = $lines $i = 0 FileClose($file) MsgBox(0, "Complete", "Corruption Complete.") Opt("GUIOnEventMode", 0) Sleep(10) Else MsgBox(48, "Error", "The selected file cannot be found. Please select a different file...") EndIf Case $Button3 _StopCheck(1) ControlEnable("*********", "", $Button1) ControlEnable("*********", "", $Button2) ControlDisable("*********", "", $Button3) EndSwitch WEnd Func _StopCheck($stop) If $stop = 1 Then $i = $lines EndIf EndFunc [left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left] 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