PDA

View Full Version : Progress Meter


dulux1309
04-23-2004, 07:30 AM
Hi all,

I am playing with a progress meter and have looked at the demo, but would like a little more power over it's usage. I would like to copy files to the hard drive, and have the meter increment after each action passes back a successful completion. At the moment, it just rattles along (abeit prettily).

Can anyone post some example code for this? Thanks in advance for your time.

kpsmith
04-23-2004, 08:05 AM
I don't have the code to back this up but heres the basic idea

First get the the total # of files that you are copying
Next set the meters range from 0 to the total # of files

Now create a loop that stops once you reach the total # of files
In that loop get a file, copy it, and then increment the meter by 1
This again will repeat until all files are copied

Hope that helps...I'll see if I can whip up an example when I get a chance

dulux1309
04-23-2004, 08:08 AM
Much appreciated - I kind of had an idea that was the way to proceed.

kpsmith
04-23-2004, 12:07 PM
This is using a status dialog which might not be what you wanted. The code should give you a good sense of how to do what you want ...


--Get all the filenames in the folder Copy at the root of the CD and put them in a table
FileTable = File.Find("Copy", "*.*", false, false, nil);
--Count the total # of files
TotalFiles = Table.Count(FileTable);

--Define count to run repeat loop
Count = 0

--Display & Define Status Dialog
StatusDlg.Show(MB_ICONNONE, false);
StatusDlg.SetTitle("Copying Files");
StatusDlg.SetStatusText("Copying Files:");
StatusDlg.SetMeterRange(1, TotalFiles);
StatusDlg.SetMeterPos(Count);

repeat

--Increment count to get next filename from the table
Count = Count+1

--Copy the file from the original location to the Paste folder at the root
File.Copy(_SourceFolder.."\\"..FileTable[Count], _SourceFolder.."\\Paste", true, true, false, true);

--Display current filename
StatusDlg.SetStatusText("Copying Files: "..FileTable[Count]);
--Change meter position
StatusDlg.SetMeterPos(Count);

--end loop once all files copied
until Count == TotalFiles

--Hide the status dialog
StatusDlg.Hide();