PDA

View Full Version : how can i do a progress bar in Zip.Add



lnd
09-27-2006, 09:45 AM
how can i do a progress bar in Zip.Add?

Worm
09-27-2006, 09:49 AM
Use the callback function, and you can set the status of a progress bar by the file, or by the whole process.

lnd
09-27-2006, 12:52 PM
i wont to get the size of the new file and check it and set the progress bar but the zip.add get a temp file and i dont no whot file to chek?

i wont to do a timer thet chek the new file size and set the progress bar but i dont no the name of the file bekose the zip.add put a temp file

and i dont no how to work whit "callback function":huh

Worm
09-27-2006, 01:09 PM
Use something like this as your callback:


function ZipCallBack(File, Percent, Status)
if Status == ZIP_STATUS_MAJOR then
-- update the over all progress bar
Progress.SetCurrentPos("OverAllProgress", Percent)
else
-- update the file's progress bar
Progress.SetCurrentPos("FileProgress", Percent)
end
end

lnd
09-27-2006, 01:16 PM
http://www.indigorose.com/forums/showthread.php?t=12946&highlight=zip

but i dont andersten it and wer i put yor code?

lnd
09-28-2006, 01:11 AM
the code run the progress bar in the zip.add

-- Display a single-selection file browse dialog
result = Dialog.FileBrowse(true, "Load File", _DesktopFolder, "Microsoft Word Document (*.zip)|*.zip|All Files (*.*)|*.*|", "", "", false, true);

-- If CANCEL was not chosen, then let's get the file path
if (result[1] ~= "CANCEL") then
Dialog.Message("You chose the following file", result[1]);
end

Zip.Add("C:\\2.Zip", result, true, "", 9, ZipCallBack, false);


function ZipCallBack(File, Percent, Status)
if Status == ZIP_STATUS_MAJOR then
-- update the over all progress bar
Progress.SetCurrentPos("Progress1", Percent)
else
-- update the file's progress bar
Progress.SetCurrentPos("Progress2", Percent)
end
end

lnd
09-28-2006, 01:35 AM
i tray this code and its dont work to


-- Display a single-selection file browse dialog
result = Dialog.FileBrowse(true, "Load File", _DesktopFolder, "Microsoft Word Document (*.zip)|*.zip|All Files (*.*)|*.*|", "", "", false, true);

-- If CANCEL was not chosen, then let's get the file path
if (result[1] ~= "CANCEL") then
Dialog.Message("You chose the following file", result[1]);
end

Zip.Add("C:\\2.Zip", result, true, "", 9, ZipCallBack, false);



function ZipCallBack(File, Percent, Status)
result444 = Progress.GetCurrentPos("Progress2");

if Status == ZIP_STATUS_MAJOR then
-- update the over all progress bar

Progress.SetCurrentPos("Progress2", result444+1)
else
-- update the file's progress bar
Progress.SetCurrentPos("Progress2", result444+1)
end
end

lnd
09-28-2006, 04:28 AM
function CallBack (sPath, nPercent, nStatus)
if nStatus == ZIP_STATUS_MAJOR then
Progress.SetCurrentPos("Progress1", nPercent);
end
end

tFiles = Zip.GetContents("AutoPlay\\Docs\\file.zip", false);

Zip.Extract("AutoPlay\\Docs\\file.zip", tFiles, _TempFolder, false, false, "", ZIP_OVERWRITE_ALWAYS, CallBack)

Worm
09-28-2006, 07:19 AM
Functions need to be defined before they can be called. If you're not going to put the function in the "Global" area, then it needs to be in your code before you call it.



-- Good
function Test()
return "Good"
end

Dialog.Message("Sample", Test())




--BAD

Dialog.Message("Sample", Test())

function Test()
return "Bad"
end

lnd
09-28-2006, 09:28 AM
function CallBack (sPath, nPercent, nStatus)
if nStatus == ZIP_STATUS_MAJOR then
Progress.SetCurrentPos("Progress1", nPercent);
end
end

dany = "c:\\1.doc";
ddd = {dany};
Zip.Add("c:\\1121.zip", ddd, true, "", 5, CallBack, true);

lnd
09-28-2006, 11:42 PM
:huh please way the code dont work

lnd
09-29-2006, 10:16 AM
help me:huh

Worm
09-29-2006, 10:18 AM
I'd gladly help you, but I don't understand what you are asking or what is wrong. It'd be a lot easier if you posted an APZ for us to look at.

lnd
09-30-2006, 02:46 AM
i send you the file

Worm
09-30-2006, 06:20 AM
Ahhhh, I see the problem, you have recurse set to true, which makes the Zip.Add function look in every sub folder of the one specified, in this case C:\.

Change that to false, and you're good to go.
Zip.Add("c:\\test.zip", zipadd, true, "", 5, CallBack, false);

lnd
09-30-2006, 09:01 AM
i fix this thenks but the new problem is the progress go to the end in 1 secend and zip.add stil work way?