Jump to content

math functions / progress bar help


keilamym
 Share

Recommended Posts

this is a portion of the script ive been testing.

$file = FileOpen($inffile, 0)

$counttotal = _FileCountLines($inffile)

$i = 0

While 1

Do

$i = $i + 1

$line = FileReadLine($file)

$ping = Ping( $line ,500)

If $reghive = "" Then

MsgBox(0,"System Error", "Please verify input data")

ExitLoop

EndIf

ProgressOn("Progress Meter", "Processing your request."," ",800,75,18)

ProgressSet($i, "Processing " & $i & " of " & $counttotal)

If $Ping Then

$results = RegRead("\\" & $line & "\" & $reghive,$regvalue)

If @error = 1 Then

_FileWriteLog($logfile, $line & ": unable to open requested key")

ElseIf @error = 2 Then

_FileWriteLog($logfile, $line & " : unable to open requested main key")

ElseIf @error = 3 Then

_FileWriteLog($logfile, $line & " : unable to open requested main key")

ElseIf @error = -1 Then

_FileWriteLog($logfile, $line & " : unable to open requested value")

ElseIf @error = -2 Then

_FileWriteLog($logfile, $line & " : value type not supported")

Else

_FileWriteLog($logfile, $line & ' : ' & $results)

EndIf

Else

_FileWriteLog($logfile, $line & " : Workstation did not Ping")

EndIf

Until $i = $counttotal

If $i = $counttotal Then

ProgressOff()

MsgBox(0,"Process Complete", "Process Complete")

ExitLoop

EndIf

WEnd

the problem im having is how the progress bar progresses to 100%... in order for the bar to show correctly, i'd need to calculate the percentage and set it as $i... is there a way to divide the total number of workstations its processed, and multiply it by 10 in order to get the correct number?

3 divided by 10 is .3

.3 x 10 would be 30%

or is there a better way...

thanks in advance

Link to comment
Share on other sites

  • 2 months later...

I am having a little trouble with implementing a progress bar into this script, I have attempted and failed. This script works fine however there is no way of knowing how long or how much longer it will take to complete. I am dealing with a large number of images, around 30,000 + so I dont expect it happen immediately. My attempt worked fine but the progress window blinked repeatedly which was not to bad but around 34% or so the progress window stops blinking and my entire desktop begins to blink. Wow what a flash back.

Here is the script before the attempt of adding the progress bar.

#include <File.au3>
;#include <Array.au3>

$dir = RegRead("HKEY_CURRENT_USER\Software\Collectorz.com\Movie\Settings", "ImageBaseFolder")
$coverjpg = _FileListToArray($dir, "*.jpg")
$covergif = _FileListToArray($dir, "*.gif")
$links = _FileListToArray($dir, "*.txt")
If @error Then
    MsgBox(0, "ERROR!!!", "No Text File Found.")
    Exit
EndIf
$database = FileRead($dir & $links[1])
$orphan = $dir & "Orphaned\"
$jmarker = 100 / $coverjpg[0]
$gmarker = 100 / $covergif[0]
If $links[0] > 1 Then
    MsgBox(0, "ERROR!", "To manny Text Files Found Please Remove old files!")
    Exit
EndIf

;<----- Search JPG Files ----->
$t = 0
$j = 0
Do
    $t = $t + 1
    $checklink = StringInStr($database, $coverjpg[$t])
    If $checklink = 0 Then
        $j = $j + 1
        $move = FileMove($dir & $coverjpg[$t], $orphan & $coverjpg[$t], 8)
    EndIf
Until $t = $coverjpg[0]

;<----- Search GIF Files ----->
$t = 0
$g = 0
Do
    $t = $t + 1
    $checklink = StringInStr($database, $covergif[$t])
    If $checklink = 0 Then
        $g = $g + 1
        $move = FileMove($dir & $covergif[$t], $orphan & $covergif[$t], 8)
    EndIf
Until $t = $covergif[0]
FileMove($dir & $links[1], $orphan & $links[1])
MsgBox(0, "Progress", "Total of " & $j + $g & " files moved")

And here is my attempt

#include <File.au3>
;#include <Array.au3>

$dir = RegRead("HKEY_CURRENT_USER\Software\Collectorz.com\Movie\Settings", "ImageBaseFolder")
$coverjpg = _FileListToArray($dir, "*.jpg")
$covergif = _FileListToArray($dir, "*.gif")
;<----- $links is a generated list of all images linked to my database, "the actual links" ----->
$links = _FileListToArray($dir, "*.txt")
If @error Then
    MsgBox(0, "ERROR!!!", "No Text File Found.")
    Exit
EndIf
$database = FileRead($dir & $links[1])
$orphan = $dir & "Orphaned\"
$jmarker = 100 / $coverjpg[0]
$gmarker = 100 / $covergif[0]
If $links[0] > 1 Then
    MsgBox(0, "ERROR!", "To manny Text Files Found Please Remove old files!")
    Exit
EndIf

;<----- Search JPG Files ----->
$t = 0
$j = 0
For $i = 0 To 100 Step $jmarker
    $p = StringFormat("%1.4s", $i)
    $t = $t + 1
    $checklink = StringInStr($database, $coverjpg[$t])
    If $checklink = 0 Then
        $j = $j + 1
        $move = FileMove($dir & $coverjpg[$t], $orphan & $coverjpg[$t], 8)
    EndIf
    ProgressOn("Progress Meter .jpg", $coverjpg[$t], "0 %")
    ProgressSet($p, "%" & $p & " " & $j & " Files Moved")
Next
ProgressSet(100, "Done", "Complete")
Sleep(500)
ProgressOff()

;<----- Search GIF Files ----->
$t = 0
$g = 0
For $i = 0 To 100 Step $gmarker
    $p = StringFormat("%1.4s", $i)
    $t = $t + 1
    $checklink = StringInStr($database, $covergif[$t])
    If $checklink = 0 Then
        $g = $g + 1
        $move = FileMove($dir & $covergif[$t], $orphan & $covergif[$t], 8)
    EndIf
    ProgressOn("Progress Meter .gif", $covergif[$t], "0 %")
    ProgressSet($p, "%" & $p & " " & $g & " Files Moved")
Next
ProgressSet(100, "Done", "Complete")
Sleep(500)
ProgressOff()


FileMove($dir & $links[1], $orphan & $links[1])
MsgBox(0, "Progress", "Total of " & $j + $g & " files moved")

Can someone tell me why this is not working? Or perhaps offer a better solution?

Thank You

Link to comment
Share on other sites

I am having a little trouble with implementing a progress bar into this script, I have attempted and failed. This script works fine however there is no way of knowing how long or how much longer it will take to complete. I am dealing with a large number of images, around 30,000 + so I dont expect it happen immediately. My attempt worked fine but the progress window blinked repeatedly which was not to bad but around 34% or so the progress window stops blinking and my entire desktop begins to blink. Wow what a flash back.

Here is the script before the attempt of adding the progress bar.

Can someone tell me why this is not working? Or perhaps offer a better solution?

Thank You

There is no way I'm going to try and reproduce the conditions to run that script, but trying to narrow it down to just the progress bar gave this code, which works fine:
Global $coverjpg[30001] = [30000]
For $n = 1 To $coverjpg[0]
    $coverjpg[$n] = "FileNumber_" & $n & ".jpg"
Next

;<----- Search JPG Files ----->
$j = 0
$t = 0
For $i = 1 To $coverjpg[0]
    $t += 1
    $p = StringFormat("%1.4s", ($i / $coverjpg[0]) * 100)
    ProgressOn("Progress Meter .jpg", $coverjpg[$t], "0 %")
    ProgressSet($p, "%" & $p & " " & $j & " Files Moved")
Next
ProgressSet(100, "Done", "Complete")
Sleep(500)
ProgressOff()

The progress bar blinks a lot, but the desktop never does. Can you modify this to reproduce your symptoms without requiring whoever runs it to have your registry entries and files present?

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

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
 Share

  • Recently Browsing   0 members

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