Skrip Posted December 25, 2006 Posted December 25, 2006 $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 $file_get = GUICtrlRead($Input1) $file = FileOpen($file_get, 2) $random1 = Random(1, _FileCountLines($file_get), 1) Why is 0 always returned? Is that enough code to work with? [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]
theguy0000 Posted December 25, 2006 Posted December 25, 2006 did you check for fileExists? the return and @error value of FileOpen? The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN
Skrip Posted December 25, 2006 Author Posted December 25, 2006 No errors...still returns 0. If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #001. Please select a different file, or restart the program.") Else GUICtrlSetData($Input1, $file_browse) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #002 at" & @error) EndIf EndIf $file_get = GUICtrlRead($Input1) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #003 at" & @error) EndIf If FileExists($file_get) Then $moveon = 1 Else $moveon = 0 EndIf If $moveon = 1 Then $file = FileOpen($file_get, 2) If @error Then MsgBox(48, "Error", "The program has encountered an error. Error #004 at" & @error) EndIf SplashTextOn("Please wait...", "Please wait... 0 of 5000", 100, 70) Do $i = $i + 1 $random1 = Random(1, _FileCountLines($file_get), 1) $random2 = Random(1, 50000) [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]
Skrip Posted December 31, 2006 Author Posted December 31, 2006 Can anybody else help? [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]
xcal Posted December 31, 2006 Posted December 31, 2006 (edited) This works for me. GUICreate('', 220, 120) $input = GUICtrlCreateInput('', 10, 10, 200, 20) $btn = GUICtrlCreateButton('find file', 10, 40, 200, 20) $label = GUICtrlCreateLabel('', 10, 80, 200, 40, $SS_CENTER) GUISetState() While 1 Switch GUIGetMsg() Case $GUI_EVENT_CLOSE Exit Case $btn Do $file = FileOpenDialog('Select a File', '', 'All (*.*)', 1) GUICtrlSetData($input, $file) If $file = '' Then MsgBox(0, 'Error', 'You must pick a file. Try again...') Until $file <> '' $file_read_from_input = GUICtrlRead($input) ;this is really unnecessary, since you can just use $file $random = Random(1, _FileCountLines($file_read_from_input), 1) GUICtrlSetData($label, 'Random number is: ' & $random) EndSwitch WEnd Edited December 31, 2006 by xcal How To Ask Questions The Smart Way
Skrip Posted December 31, 2006 Author Posted December 31, 2006 $file = FileOpen($file_get, 2); This will erase the contents of the file. Use a different flag like 1 or 0 I can't belive I made such a stupid mistake! It works fine now. Thanks [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]
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