PDA

View Full Version : Callback function In Zip.Add and Zip.Extract


hani
06-23-2007, 05:30 PM
i need to know how to use the callback function with zipping and extracting files using a custom progress object and a custom cancel bottom so that they will appear in a specific position in the application and i just want the overall progress .. can anyone help me plzzzzz... :rolleyes

RizlaUK
06-24-2007, 08:22 AM
Hi,

heres a chunk of code i pulled from a old (unfinished) zip app i was working on a while ago, it uses progress bars and labels to show the current status

you might be able to pick out what you need, or these functions are good to go as thay are (just change the names of the objects)

function ZipCallBack(File, Percent, Status)
if Status == ZIP_STATUS_MAJOR then
Progress.SetText("TotalProgress", Percent.."%");
Progress.SetCurrentPos("TotalProgress", Percent)
else
Progress.SetText("CurrentProgress", Percent.."%");
Progress.SetCurrentPos("CurrentProgress", Percent)
Label.SetText("laFileProgress", File);
end

if Abort then
return false
else
return true
end
end

function ResetProgress()
Progress.SetText("TotalProgress", 0);
Progress.SetCurrentPos("TotalProgress", 0)
Progress.SetText("CurrentProgress", 0);
Progress.SetCurrentPos("CurrentProgress", 0)
Label.SetText("laFileProgress", "");
Button.SetVisible("btnCancel", false);
end

function OpenZip()
if Abort then
Abort = false
end
GetFile = Dialog.FileBrowse(true, "Locate Zip File", _DesktopFolder, "All Files (*.*)|*.*|", "", "dat", false, false);
if GetFile[1] == "CANCEL" then
Application.ExitScript();
else
GetFolder = Dialog.FolderBrowse("Please select a folder to extract to:", _DesktopFolder);
if GetFolder == "CANCEL" then
Application.ExitScript();
else
Button.SetVisible("btnCancel", true);
Zip.Extract(GetFile[1], {"*.*"}, GetFolder, true, true, "", ZIP_OVERWRITE_ALWAYS, ZipCallBack);
ResetProgress()
err = Application.GetLastError();
if (err ~= 0) then
Dialog.Message("Error", _tblErrorMessages[err], MB_OK, MB_ICONEXCLAMATION);
end
end
end
end

OpenZip();

to cancel the zip, make a button and put in the on click,
Abort = true


or if it makes it easier for you, heres the apz

hani
06-27-2007, 04:43 PM
really thanx maan thats exactly wt i was asking fooooooor :yes

poo
11-28-2007, 11:21 PM
After many hours of trial and error
After many hours of google
After many hours of Searching this forum
I finally found this post and it finally gave a good working custom progress meter
So with that being said, RizlaUK I thank-you so very much
yes i know its a old post but that matters not it helped me greatly
and also if any one else has posted similar info i'm sorry, it just wasnt dummied down enough for me

odracir
12-04-2007, 03:58 AM
:eek::eek: yeah this is what im looking for!!!! but maybe some edits??

ComboBox.AddItem("ComboBox1", "Desktop", Shell.GetFolder(SHF_DESKTOP));

whats the line for my autorun cd docs???:huh

and whats the code for extracting always to my documents??

but this example rules!!!!!!!

odracir
12-07-2007, 12:23 PM
:huh:huh:huh
nobody can helps with this??

longedge
12-07-2007, 01:45 PM
My documents is Shell.GetFolder(SHF_MYDOCUMENTS)

The docs folder of your project no matter where the application is running from is "AutoPlay\\Docs\\name_of_file.extension"

raivenz
08-24-2008, 07:55 AM
when i hit the cancel button.
the progress zip file extract still continue?
why it doesnt stop the zip file extraction?

br, raivenz