bubke Posted March 9, 2008 Share Posted March 9, 2008 (edited) Hello, I'm making a program what reads a file and shows the content in a edit control. All i want to do is making a progressbar, so that i can monitor the status of the file reading, because the log files a very big. The problem is that the progressbar hangs in a loop. I don't understand what i'm doing wrong. I hope someone can help me. I will show the code of the function. Grtz. The code: Func OpenFile() _GUICtrlEdit_SetText($iMemo2, "") If FileExists(@ScriptDir & "\copy_logfile.txt") Then FileDelete(@ScriptDir & "\copy_logfile.txt") $sPath = FileOpenDialog('Open Files', "C:\Temp\logs", 'Logfiles (*.*)') If @error = 1 Then MsgBox(16, "Error!", "You haven't open any log file!") Return EndIf GUICtrlSetData($Label4, $sPath) FileCopy($sPath, @ScriptDir & "\copy_logfile.txt") $temp_copy = @ScriptDir & "\copy_logfile.txt" GUICtrlSetFont($iMemo2, 9, 400, 0, "Courier New") $i = 0 $Total_lines = _FileCountLines($temp_copy) ProgressOn("Progress Meter", "Increments every second", "0 percent") While 1 $sMessage2 = FileReadLine($temp_copy, $i) _GUICtrlEdit_AppendText($iMemo2, $sMessage2) If $i = @error -1 Then ExitLoop Else $i = $i + 1 ProgressSet( $i, $i & " percent") EndIf WEnd ;Next ProgressSet(100 , "Done", "Complete") sleep(500) ProgressOff() EndFunc Edited March 9, 2008 by bubke Link to comment Share on other sites More sharing options...
AdmiralAlkex Posted March 9, 2008 Share Posted March 9, 2008 Looks to me like the problem is this line: If $i = @error -1 Then that line doesn't make any sense at all and will never be true .Some of my scripts: ShiftER, Codec-Control, Resolution switcher for HTC ShiftSome of my UDFs: SDL UDF, SetDefaultDllDirectories, Converting GDI+ Bitmap/Image to SDL Surface Link to comment Share on other sites More sharing options...
bubke Posted March 9, 2008 Author Share Posted March 9, 2008 (edited) Hi, thanks for your suggestion. @error -1 means that if the end of the file is reached. I've changed it in : edited on 18:35: $i = 0 $progressbar = GUICtrlCreateProgress (10,15,200,20,$PBS_SMOOTH) For $i = 0 To 100 $sMessage2 = FileRead($temp_copy) GUICtrlSetData ($progressbar,$i) $i = $i + 1 Next ProgressOff() It works, but it's a little bit slow. If someone has an improvement, then I'm glad to hear. Grtz. Edited March 9, 2008 by bubke 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