PDA

View Full Version : Zip.Extract question!


odeen_c
07-31-2006, 12:15 PM
hi,

i have to extract from a zip file some files. i've used zip.extract action, and a callbackFunction to show the progress of operations. The problem is that the var "Percent" of the callbackfunc. shows the "progress status" for every file in the zip. is that possible to have a status percent. that corresponds to the progress of the action as a whole (for all files)?

i hope i've explained myself.

thanks

TJ_Tigger
07-31-2006, 06:31 PM
hi,

i have to extract from a zip file some files. i've used zip.extract action, and a callbackFunction to show the progress of operations. The problem is that the var "Percent" of the callbackfunc. shows the "progress status" for every file in the zip. is that possible to have a status percent. that corresponds to the progress of the action as a whole (for all files)?

i hope i've explained myself.

thanks


As part of the callbackfunction look at the status field. This is from the help file.

Status
(number) The status of the current callback message. Either ZIP_STATUS_MAJOR or ZIP_STATUS_MINOR. ZIP_STATUS_MAJOR means that the callback corresponds to the progress of the action as a whole. ZIP_STATUS_MINOR means that the callback corresponds to the progress of the current file.

Check to see if it is ZIP_STATUS_MAJOR or ZIP_STATUS_MINOR and only use the ZIP_STATUS_MAJOR to show the progress of the extraction as a whole.

odeen_c
08-01-2006, 05:04 AM
I did it in another way.
however, the var "Status" doesn't give me a percentage of the progress but only "1" for ZIP_STATUS_MINOR and "0" for ZIP_STATUS_MAJOR.

TJ_Tigger
08-01-2006, 07:08 AM
I did it in another way.
however, the var "Status" doesn't give me a percentage of the progress but only "1" for ZIP_STATUS_MINOR and "0" for ZIP_STATUS_MAJOR.

That is correct. This status determines if the returned percentage is for an individual file or for the zip file as a whole. So you can perform an if then statement to see if it is Major and if it is then use it to update your progress bar as appropriate.

Tigg

Intrigued
08-01-2006, 09:08 AM
Here is an example (I.R. member Desmond did this one):

function CallBack (sPath, nPercent)
--if one file is done, incriment the current file
if nPercent == 100 then
nCurrentFile = nCurrentFile + 1;
end
--this statement prevents incorrect display (eg 3of2)
if nCurrentFile <= nEnd then
StatusDlg.SetTitle("Unzipping!!!");
StatusDlg.SetMessage(sPath);
StatusDlg.SetStatusText("File " .. nCurrentFile .. " of " .. nEnd .. ".");
StatusDlg.SetMeterPos(nCurrentFile);
StatusDlg.SetMeterRange(1, nEnd);
end
end

--get the contents of the zip file
tFiles = Zip.GetContents("AutoPlay\\Docs\\file.zip", false);

--these variables are used in the callback function
nCurrentFile = 1;
nEnd = Table.Count(tFiles);
--end callback function variables

--unzip the files
StatusDlg.Show(0, false);
Zip.Extract("AutoPlay\\Docs\\file.zip", tFiles, _TempFolder, false, false, "", ZIP_OVERWRITE_ALWAYS, CallBack)
StatusDlg.Hide();

TJ_Tigger
08-01-2006, 10:02 AM
Here is a sample project showing the use of nStatus within a project.
The zip file will be created on the project startup. I also have a sleep command in the callback function to slow the process down so it is easier to watch. Just comment it out to have it go faster.

Tigg

odracir
08-01-2006, 11:19 AM
:D nice work tigger !!! ,
but is it possible with a .exe when installing???

please with an example????

noob scripter in here :o

TJ_Tigger
08-01-2006, 11:27 AM
but is it possible with a .exe when installing???


I don't understand your question.

Can I make the project an EXE and have it do the same thing? Sure
Can I extract files from a self-executing zip archive? don't know have not tried
Can I show the status dialog when installing from an EXE file? Not that I am aware of.

odracir
08-01-2006, 01:18 PM
i made a file with sfx to .exe file....
when on button click,
it runs the same as the zip extraction.
so when installing you see the progress running.....
and is it possible to change the color of the progressbar???


greetz ricardo

rhosk
08-01-2006, 01:27 PM
greetz ricardo

I'm guessing that you're 'clubcrusher' in disguise. Just a guess -


http://indigorose.com/forums/showthread.php?t=16767&highlight=greetz

odracir
08-01-2006, 02:15 PM
:huh who's that ron???

greetz is like greeting term in holland ????

Intrigued
08-01-2006, 07:14 PM
lol

It's hard to get one past Ron. Maybe I.R. should let him Admin the boards.

;)

Intrigued
08-01-2006, 08:50 PM
:D nice work tigger !!! ,
but is it possible with a .exe when installing???

please with an example????

noob scripter in here :o

This may work for you.

I adjusted TJ_TIGGERs code a bit for the following example:

Updated (forgot to add in TJ's zip file):

http://www.amsuser.com/ams/examples/UnzipSilently-AMS6-Intrigued.apz

Note: I set the files to unzip to a folder on the user's Desktop for easy visual and then removal as well.

odeen_c
08-03-2006, 07:57 AM
That is correct. This status determines if the returned percentage is for an individual file or for the zip file as a whole. So you can perform an if then statement to see if it is Major and if it is then use it to update your progress bar as appropriate.

Tigg

oh hadn't seen it like this. ill try it.

thank you very much. and thanks to intrigued too.
:)

Intrigued
08-03-2006, 07:45 PM
Ya, TJ get's the lion's share of the credit on that one. But, you are welcome.