Jump to content

Recommended Posts

Posted

G'day everyone

I have a script that processes a large file. I would like the script to give me some progress report every now and then. I don't particularly care how... it can tell me every mintue how far it is, or it can tell me every 100 iterations of a loop how far it is.

Here's a section of the script:

For $i = 1 to $wflines

$line = FileReadLine ($wftmfile, $i)
If StringInStr ($line, "=" & $lookfor, 1) Then
FileWriteLine ($outputfile, $line)
EndIf

Next

The file being processed has about 250 000 lines, so it would be very kind of the script to tell me every now and then how far it is. Any ideas how to do this? It doesn't have to be elegant.

Thanks!

Samuel

Posted (edited)

Just for fun I decided to create a simple seconds to HH:MM:SS function:

#include <GUIConstants.au3>

$STAMP = TimerInit()

GUICreate("My GUI", 200, 70)  ; will create a dialog box that when displayed is centered
GUISetState (@SW_SHOW)       ; will display an empty dialog box

$TimeLBL = GUICtrlCreateLabel ("",5,5,190,60)
GUICtrlSetFont (-1,35, 400)

Func ConvertSecondsToHHMMSS($seconds)
    $Hour = Int($seconds / 360)
    $Mins = Int(Mod($seconds,360) / 60)
    $Secs = Mod(Mod($seconds,360), 60)
    
    Return StringFormat("%02i:%02i:%02i", $Hour, $Mins, $Secs)
EndFunc

; Run the GUI until the dialog is closed
While 1
    $msg = GUIGetMsg()
    
    ;Return time in seconds
    $TimeDiff = TimerDiff($STAMP) / 1000
    GuiCtrlSetData($TimeLBL,ConvertSecondsToHHMMSS($TimeDiff))
    Sleep(250)
    
    If $msg = $GUI_EVENT_CLOSE Then ExitLoop
Wend
Edited by weaponx
Posted (edited)

G'day everyone

I have a script that processes a large file. I would like the script to give me some progress report every now and then. I don't particularly care how... it can tell me every mintue how far it is, or it can tell me every 100 iterations of a loop how far it is.

Here's a section of the script:

For $i = 1 to $wflines

$line = FileReadLine ($wftmfile, $i)
If StringInStr ($line, "=" & $lookfor, 1) Then
FileWriteLine ($outputfile, $line)
EndIf

Next

The file being processed has about 250 000 lines, so it would be very kind of the script to tell me every now and then how far it is. Any ideas how to do this? It doesn't have to be elegant.

Thanks!

Samuel

Something like this maybe

$Size = FileGetSize($filename)
$wftmfile = FileOPen($filename,0)
$position = 0
$fact = 1;if ascii file
$Progress1 = GUICtrlCreateProgress(10,20,120,10)
For $i = 1 to $wflines

    $line = FileReadLine ($wftmfile, $i)
    $position += StringLen($line * $fact + 1);+1 to allow for CR in file which is not part of $line
    GUICtrlSetData($progress1,$position *100/$Size)
    If StringInStr ($line, "=" & $lookfor, 1) Then
        FileWriteLine ($outputfile, $line)
    EndIf

Next
FileClose($wftmfile)
Edited by martin
Serial port communications UDF Includes functions for binary transmission and reception.printing UDF Useful for graphs, forms, labels, reports etc.Add User Call Tips to SciTE for functions in UDFs not included with AutoIt and for your own scripts.Functions with parameters in OnEvent mode and for Hot Keys One function replaces GuiSetOnEvent, GuiCtrlSetOnEvent and HotKeySet.UDF IsConnected2 for notification of status of connected state of many urls or IPs, without slowing the script.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...