WLanguage procedure ("Callback") used by
zipAddFile to manage the progress of files being added to the archive.
If you use a TAR or TGZ (TAR.GZ) archive, the progress is refreshed only after the file is added.
// -- Initialization code of window
GLOBAL
ArchiveName is string = "MyArchive"
// -- Click code on BTN_AddFile
// Initialization code
FileName is string
CreationErrorCode is int
AdditionErrorCode is int
EventNum is int
// Create an archive
CreationErrorCode = zipCreate(ArchiveName, "C:\MyDirectory\MyArchives\PdfArchive.wdz")
// Display an error message if the archive was not created
IF CreationErrorCode = 0 THEN
// Select the file to add
FileName = fSelect("", "", "File to add", ...
"File to compress" + TAB + "*.*", "*", fselOpen + fselExist)
// Add the selected file to the archive
AdditionErrorCode = zipAddFile(ArchiveName, FileName, zipNone, Compression_ProgressBar)
// Display an error message if the file was not added
IF AdditionErrorCode <> 0 THEN
Error(zipMsgError(AdditionErrorCode))
END
ELSE
Error(zipMsgError(CreationErrorCode))
END
// Internal procedure used for the progress bar.
INTERNAL PROCEDURE Compression_ProgressBar(CurrentFile is string, Percentage is int)
IF Percentage < 100 THEN
ProgressBar(Percentage, 100, CurrentFile)
// Refresh the window
Multitask(-1)
ELSE
// The compression is over
ProgressBar()
END
END
Syntax
zipAddFile_Callback(<Current file> , <Progress percentage>)
<Current file>: Character string
Name of the file being processed.
<Progress percentage>: Integer
Progress percentage of the file being added to the archive.