DCCD Posted July 15, 2009 Share Posted July 15, 2009 this works, but "fileReadLine" finish before "progress bar" Any idea how to fix this? #include <GUIConstants.au3> $Source = "C:\20080426(002).data";1Gb! $total = FileGetSize($Source) $F = FileOpen($Source, 0) $count = 0 $GUI = GUICreate("GUI",400,60,-1,-1) $GUIProgress = GUICtrlCreateProgress (10,10,380,40) GUISetState (@SW_SHOW) while 1 $line = FileReadLine($F) If @error = -1 Then ExitLoop $count = $count + StringLen($line) $iPercentage = Round(($count/$total)*100) GUICtrlSetData($GUIProgress, $iPercentage) WEnd FileClose($F) [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group Link to comment Share on other sites More sharing options...
Yashied Posted July 15, 2009 Share Posted July 15, 2009 this works, but "fileReadLine" finish before "progress bar" Any idea how to fix this? #include <GUIConstants.au3> $Source = "C:\20080426(002).data";1Gb! $total = FileGetSize($Source) $F = FileOpen($Source, 0) $count = 0 $GUI = GUICreate("GUI",400,60,-1,-1) $GUIProgress = GUICtrlCreateProgress (10,10,380,40) GUISetState (@SW_SHOW) while 1 $line = FileReadLine($F) If @error = -1 Then ExitLoop $count = $count + StringLen($line) $iPercentage = Round(($count/$total)*100) GUICtrlSetData($GUIProgress, $iPercentage) WEnd FileClose($F) You must take into account the @CRLF. My UDFs: iKey | FTP Uploader | Battery Checker | Boot Manager | Font Viewer | UDF Keyword Manager | Run Dialog Replacement | USBProtect | 3D Axis | Calculator | Sleep | iSwitcher | TM | NetHelper | File Types Manager | Control Viewer | SynFolders | DLL Helper Animated Tray Icons UDF Library | Hotkeys UDF Library | Hotkeys Input Control UDF Library | Caret Shape UDF Library | Context Help UDF Library | Most Recently Used List UDF Library | Icons UDF Library | FTP UDF Library | Script Communications UDF Library | Color Chooser UDF Library | Color Picker Control UDF Library | IPHelper (Vista/7) UDF Library | WinAPI Extended UDF Library | WinAPIVhd UDF Library | Icon Chooser UDF Library | Copy UDF Library | Restart UDF Library | Event Log UDF Library | NotifyBox UDF Library | Pop-up Windows UDF Library | TVExplorer UDF Library | GuiHotKey UDF Library | GuiSysLink UDF Library | Package UDF Library | Skin UDF Library | AITray UDF Library | RDC UDF Library Appropriate path | Button text color | Gaussian random numbers | Header's styles (Vista/7) | ICON resource enumeration | Menu & INI | Tabbed string size | Tab's skin | Pop-up circular menu | Progress Bar without animation (Vista/7) | Registry export | Registry path jumping | Unique hardware ID | Windows alignment More... Link to comment Share on other sites More sharing options...
GEOSoft Posted July 15, 2009 Share Posted July 15, 2009 (edited) FileGetSize is not a good way to actually get the what you are looking for since FileReadLine() strips @CR & @LF. This function isn't tested but it should be pretty close. $Total = _StringSize($Source) Func _StringSize($sStr) If FileExists($sStr) Then $sStr = FileRead($sStr) Local $iSize = StringLen(StringReplace(StringStripCR($sStr)), @LF, "") Return $iSize EndFunc Another way would be this $Total = _StringSize($Source) Func _StringSize($sStr) If FileExists($sStr) Then $sStr = FileRead($sStr) StringRegExpReplace($sStr, "\V", "") Local $iSize = @Extended Return $iSize EndFunc Edited July 15, 2009 by GEOSoft George Question about decompiling code? Read the decompiling FAQ and don't bother posting the question in the forums.Be sure to read and follow the forum rules. -AKA the AutoIt Reading and Comprehension Skills test.*** The PCRE (Regular Expression) ToolKit for AutoIT - (Updated Oct 20, 2011 ver:3.0.1.13) - Please update your current version before filing any bug reports. The installer now includes both 32 and 64 bit versions. No change in version number. Visit my Blog .. currently not active but it will soon be resplendent with news and views. Also please remove any links you may have to my website. it is soon to be closed and replaced with something else. "Old age and treachery will always overcome youth and skill!" Link to comment Share on other sites More sharing options...
KaFu Posted July 15, 2009 Share Posted July 15, 2009 (edited) Strange, even taking line feeds into account I didn't came nearly anywhere the real filesize. Anyway, filereadline() is quiet slow. Is it really necessary, esp. parsing a 1GB file? #include <GUIConstants.au3> $Source = "C:\20080426(002).data" ;1Gb! $total = FileGetSize($Source) $F = FileOpen($Source, 0) $count = 0 $GUI = GUICreate("GUI",400,60,-1,-1) $GUIProgress = GUICtrlCreateProgress (10,10,380,40) GUISetState (@SW_SHOW) $BufferSize = 1024 * 10 ; 10kb For $i = 1 To Ceiling($total / $BufferSize) $line = FileRead($F, $BufferSize) $count += $BufferSize $iPercentage = Round(($count/$total)*100) GUICtrlSetData($GUIProgress, $iPercentage) Next FileClose($F) Edited July 15, 2009 by KaFu OS: Win10-22H2 - 64bit - German, AutoIt Version: 3.3.16.1, AutoIt Editor: SciTE, Website: https://funk.eu AMT - Auto-Movie-Thumbnailer (2022-Nov-26) BIC - Batch-Image-Cropper (2023-Apr-01) COP - Color Picker (2009-May-21) DCS - Dynamic Cursor Selector (2024-Feb-16) HMW - Hide my Windows (2018-Sep-16) HRC - HotKey Resolution Changer (2012-May-16) ICU - Icon Configuration Utility (2018-Sep-16) SMF - Search my Files (2023-Jun-03) - THE file info and duplicates search tool SSD - Set Sound Device (2017-Sep-16) Link to comment Share on other sites More sharing options...
DCCD Posted July 15, 2009 Author Share Posted July 15, 2009 (edited) @GEOSoft, Thanks "both" function works, but with small files!, fails reading 1GB file, see attached pic! My files between 1GB and 4GB. @KaFu, Thank you so much, WORKS 100%, but takes forever!!! Edited July 15, 2009 by DCCD [u][font=Arial Black]M[/font]y Blog, AVSS Parts[/u][font=Arial Black]Else[/font][font=Arial Black]L[/font]ibya Linux Users Group 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