Estimated Time Copy (Callback)
Buenas amigos de AMSSpecialist, el otro dia se me ocurrio la idea de hacer que un callback calcule el tiempo que a pasado y el restante, espero que os guste la idea y os ayude a perfeccionar vuestros proyectos.
Callback:
Llamada:
Ejemplo:
Buenas amigos de AMSSpecialist, el otro dia se me ocurrio la idea de hacer que un callback calcule el tiempo que a pasado y el restante, espero que os guste la idea y os ayude a perfeccionar vuestros proyectos.
Callback:
function CopyCallback(sSrcFile, sDstFile, nCopBytes, nTotBytes, nCopBytesCurFile, nTotBytesCurFile)
if ayt == nil then
ayt = Math.Floor(nTotBytes/100)
tm1 = os.clock();
end
if _1a == nil then
if nCopBytes > (ayt) then
stimatedTotal = Math.Floor((os.clock()-tm1)*100);
_1a = true;
end
end
if _10a == nil then
if nCopBytes > (ayt*10) then
stimatedTotal = Math.Floor((os.clock()-tm1)*10);
_10a = true;
end
end
if _50a == nil then
if nCopBytes > (ayt*50) then
stimatedTotal = Math.Floor((os.clock()-tm1)*2);
_50a = true;
end
end
stimated = Math.Floor((os.clock()-tm1));
if stimatedTotal == nil then
stimatedTotal = "calculated";
end
Paragraph.SetText("Paragraph1", "Time: "..stimated.." seconds of "..stimatedTotal.." seconds.");
end
result = Dialog.FolderBrowse("Please select a folder to copy:", "");
if result ~= "" then
Folder.Create(_TempFolder.."\\estimated_temp");
File.Copy(result.."\\*.*", _TempFolder.."\\estimated_temp\\", true, true, false, true, CopyCallback);
Paragraph.SetText("Paragraph1", "Total Time: "..os.clock()-tm1.." seconds.");
Folder.DeleteTree(_TempFolder.."\\estimated_temp", nil);
end