Jump to content
Sign in to follow this  
cracksys

Progress Bar with no progress

Recommended Posts

cracksys

CODE
$dirsize_before = DirGetSize("E:\Briefcase\", 1)

$dirsize_cur = $dirsize_before

$percent = 100

ProgressOn("Briefcase Backup!", "", "Removing Briefcase directory ...", -1, -1, 1)

DirRemove("E:\Briefcase\", 1)

While $percent > 0

$dirsize_cur = DirGetSize("E:\Briefcase\", 1)

$percent = ($dirsize_cur *100) / $dirsize_before

ProgressSet( $percent, "Removing Briefcase directory ... " & $dirsize_before & "%", "")

WEnd

Progress bar will appear before folder romoval but its stayed there forever without any progress shown. Even after folder has been completely removed.

Edited by cracksys

Share this post


Link to post
Share on other sites
Authenticity

Read again the function definition of DirGetSize(). It returns an array type if the second parameter is 1 so something like:

$dirsize_cur = DirGetSize("E:\Briefcase\", 1)
$percent = ($dirsize_cur *100) / $dirsize_beforeoÝ÷ Ú+½©nj׶®¶­sbb33c¶F'6¦Uö7W"ÒF$vWE6¦RgV÷C´S¢b3#´'&Vf66Rb3#²gV÷C²Â¢b33c·W&6VçBÒ£òb33c¶F'6¦Uö&Vf÷&R²÷6öÖWFærÒ

Share this post


Link to post
Share on other sites
cracksys

Silly me. So, it should've been like this :

$percent = ($dirsize_cur[0] *100) / $dirsize_before[0]

Correct? -- I'm sorry, at office right now so no testing.

Edited by cracksys

Share this post


Link to post
Share on other sites
Authenticity
:) ... on success. Always check if a variable is of array type before accessing it's subscript members, so you can do yourself a favor and use IsArray, exactly as in the function example script in the help file. Edited by Authenticity

Share this post


Link to post
Share on other sites
cracksys

Thanks. I tried but I failed.

$dirsize_before = DirGetSize("E:\Briefcase\", 1)
            $dirsize_cur = DirGetSize("E:\Briefcase\", 1)
            ProgressOn("Briefcase Backup!", "", "Removing Briefcase directory ...", -1, -1, 1)
            If IsArray($dirsize_before) Then
                DirRemove("E:\Briefcase\", 1)
                Do
                    $percent = $dirsize_cur[0] * 100 / $dirsize_before[0]
                    ProgressSet( $dirsize_cur[0] * 100 / $dirsize_before[0], "Removing Briefcase directory ... " & $percent, "")
                Until $dirsize_cur[1] = 0
                ProgressOff()
            EndIf

Folder will be removed but progress bar start updating after that and its kept looping.

Share this post


Link to post
Share on other sites
Authenticity

I guess that it's because you're not updating the variable. If $dirsize_cur[1] is 65 files when entering the loop, it'll be so forever because nothing is updating the variable. You need to call DirGetSize() also while in the loop, don't know if it'll return something because technically you've removed this directory.

Share this post


Link to post
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
Sign in to follow this  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.