PDA

View Full Version : help needed with download progress meter


mystica
06-19-2009, 06:35 PM
Anyone know how to add to this code to get the progress-meter to also display download-speed (transfer-rate) in kb/s?

function DownloadCallback(BytesSoFar,TotalBytes)
strProgressText = "";
if(TotalBytes ~= 0)then
dload_pct = ((BytesSoFar/TotalBytes) * 100);
strProgressText = "Downloading... "..BytesSoFar.." bytes of "..TotalBytes.." bytes completed";

Progress.SetText("progress",Math.Ceil(dload_pct).."%");
else
strProgressText = "Downloading... "..BytesSoFar.." bytes completed";
dload_pct = 0;
end
Progress.SetCurrentPos("progress",dload_pct);
Label.SetText("lblProgress",strProgressText);
if(bCancelled)then
return false;
else
return true;
end
end

bCancelled = false;

Here's the the apz.file to give a better picture of what I'm trying to tinker with.
NB. This apz. file is not mine ... it's been posted before by someone else, but I'd like to be able to add a transfer-rate dialogue (in kb/s) to it. I've read the relevant posts on this topic but can't get it to work. Would anyone like to have a go at downloading the apz-file and making the necessary adjustments? (Relevant code is on PageProperties onPreload).