View Full Version : Code Request
jcuster
09-17-2007, 09:15 AM
If I have a table containing several files, I am copying them to another location. How can I code a Time Left for the user?
such as xx:xx Time Remaining.
Thanks
jassing
09-17-2007, 10:05 AM
You'd have to use a callback function and use a global variable and calculate time left based on copy rate...
jcuster
09-17-2007, 02:33 PM
You'd have to use a callback function and use a global variable and calculate time left based on copy rate...
I have the callback function and a Global variable would be easy but how do you figure out Copy rate.
Global Variable1 is the (Total Files)
Global Variable2 is the(Current File)
Dividing Variable 2 into 1 gives the 50%
Dividing Variable 1 into 2 gives 2
Now How can I make this work?
jassing
09-17-2007, 02:51 PM
You need to use know the time elapsed; then calculate the time elapsed vs bytes copied -- use that as a percentage of total bytes, then calculate out bytes remaining.. at 1st the estimated time will be off and change rapidly; but it should soon settle down to a only slightly varying estimation...
jcuster
09-17-2007, 03:51 PM
You need to use know the time elapsed; then calculate the time elapsed vs bytes copied -- use that as a percentage of total bytes, then calculate out bytes remaining.. at 1st the estimated time will be off and change rapidly; but it should soon settle down to a only slightly varying estimation...
Global Variable1 is the (Total Bytes)
Global Variable2 is the(Bytes Copied so far)
Variable (Start Time)
Variable (End Time)
Elapsed (Start Time - End Time)
Variable2 is Percent of Varible1
Subtract (Variable2 from 1)
Im thinking that will be expressed as a percent but not as SS:MM?
jcuster
09-18-2007, 12:35 PM
My functions are;
function COPYCB(Source,Destination,Copied,Total)
DlgProgressBar.SetPos(CTRL_PROGRESS_BAR_02, (nfl / nflcnt) * 100);
BytesCSF = BytesCSF + Copied
E_Time = System.GetTime(TIME_FMT_MIN)..":"..System.GetTime(TIME_FMT_SEC)
End_Time = Time2Num(E_Time)
Elapsed = End_Time - Start_Time
TEvsBC = Elapsed / BytesCSF
Current_Percent = TEvsBC / TBytes
Display_TL = Math.Round(Current_Percent,0)
Display_TL = Time2Str(Display_TL)
--Dialog.TimedMessage("Please Wait...", End_Time.." "..Start_Time.." "..Elapsed.." "..BytesCSF.." "..TBytes.."\r\n", 500, MB_ICONINFORMATION);
return true; --continue copying
end
function Time2Num(Tme)
Raw_Min = String.ToNumber(String.Left(Tme, 2));
Raw_Sec = String.ToNumber(String.Mid(Tme, 4, 2));
Num_Time = (Raw_Min * 59) + Raw_Sec
Tme = Num_Time
return Tme
end
function Time2Str(Tme)
Str_Min = Math.Round((Tme /59), 0);
Str_Sec = Math.Mod(Tme, 59)
Num_Time = Str_Min..":"..Str_Sec
Tme = Num_Time
return Tme
end
function gtbs(Path)
local nSize = File.GetSize(Path);
TBytes = g_FolderSize + nSize;
return true;
end
My Calls are:
TBytes = 0
BytesCSF = 0
Start_T = System.GetTime(TIME_FMT_MIN)..":"..System.GetTime(TIME_FMT_SEC)
Start_Time = Time2Num(Start_T)
File.Copy(tfiles[n], Sdest..dest, true, true, true, true, COPYCB);
My "Time Left" seems to get larger and larger. I think I may be missing a step somewhere
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.