PDA

View Full Version : Progress bar - problems


mangomel
08-18-2008, 04:56 PM
I'm rather newbie in writting scripts in AMS.
Well, my app should copy some files from internal - Docs folder into given location and show progress, precents in progressbar. I had not so good idea how to do it so I read so some posts and examples on forum. And I copied almost whole function script from project of application which downloades files. Look:

--after some checking if everything have gone ok, app jumps to the next page and immediately copies some files, f.e.:
--on show:

copy1 = File.Copy("AutoPlay\\Docs\\file.dat", mydestination, true, true, false, true, progress); etc.

--on preload I pasted and edited this:

function progress(Copied,Total)
copiednumber = String.ToNumber(Copied);
totalnumber = String.ToNumber(Total)

if(totalnumber ~= 0)then
dload_pct = ((copiednumber/totalnumber) * 100);
Progress.SetText("Progress1", Math.Ceil(dload_pct).."%");
else
dload_pct = 0;
end
Progress.SetCurrentPos("Progress1", dload_pct);
if(bCancelled)then
return false;
else
return true;
end
end

It doesn't work. I checked that function receives Total = "file patch is being copied" not "some bytes". What's going on?