Progress Bar Object and File Copy

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • WallyWonka
    Forum Member
    • Dec 2007
    • 28

    Progress Bar Object and File Copy

    in my AMS project I have a button that would like to copy files from my project onto a users computer, and I would like to use a progress bar object rather than a status dialog message to display the progress of the files being copied. I referred to the help documents and I scoured the forums with no clear examples, the best I found was something like this:

    Progress.SetVisible("Progress1", true);
    function CopyCallback(a,b,c,d,e)
    Progress.StepIt( "Progress1")
    return true
    end

    File.Copy("Docs\\*.*", strFilePath, true, true, false, true, CopyCallback);
    Progress.SetVisible("Progress1", false);

    This doesn't work too well because while the files are being copied the progress bar object is not in synch with the actual file copy process, it blinks erratically. The settings on the Progress object are the default settings, Range 0-100...Step is 10...XP Style...Bars. So am I getting the code wrong? Am I suppose to add other codes elsewhere? Any help would be greatly appreciated as I have spent hours trying to figure this out. Thank you.
  • WallyWonka
    Forum Member
    • Dec 2007
    • 28

    #2
    Well with enough patience and a little tenacity, I was able to figure out how to do it. I'll post it here anyway in case someone else decides to search the forums with the same issue I was having. Here is the fix:

    Progress.SetVisible( "Progress1", true)
    function FileProgress(Source, Destination, Copied, Total, FileCopied, FileTotal)
    rounded = Math.Round((Copied/Total) * 100, 1);
    Progress.SetCurrentPos("Progress1", ((Copied/Total) * 100))
    return true
    end

    File.Copy("AutoPlay\\Docs*.*", strFilePath, true, true, false, true, FileProgress);

    Progress.SetVisible( "Progress1", false)


    Place that code in the 'On Click' event variable for your button, text object or other plugin. A progress bar of the files being copied will be seen within the project window, which can be nifty. Remember to add the actual Progess object to the AMS project. Leave Progress Properties to the default settings, unless you wanna tinker with them. Take care.

    Comment

    Working...
    X