In order to compress a file or folder, using the zip format, you need to specify a valid absolute file name for the archive that will be also an identifier for the archive, example:

revZipOpenArchive "C:/", "write"

Then you have to specify all the files that you want to compress, but you must supply an absolute path. You can't use relative paths. If you want to create one or more folder inside the archive, just add the folder name before the file name. Example on Windows:

 revZipAddItemWithFile "C:/", "test.txt", "C:/Programs/RunRev/test.txt"
 revZipAddItemWithFile "C:/", "folder1/test.txt", "C:/Programs/RunRev/test.txt"
 revZipAddItemWithFile "C:/", "temp/folder2/test.txt", "C:/Programs/RunRev/test.txt"

After you specified the files to compress, you have to close the archive. Only after closing the archive Livecode will write the archive on the disk. Example:

revZipCloseArchive "C:/"

You must alway use absolute paths, this way you can work with many archives at time without having any error.

If you want to decompress an archive (unzip), you have to get the list of the file and create the necessary subdirectories before extracting the items in the zip archive. The following code shows the button code for requesting and decompressing a ZIP file on the desktop of Windows:

on mouseUp
  answer file "Choose a file to unzip:"
  put it into myzip
  revZipOpenArchive myzip,"read"
  put revZipEnumerateItems(myzip) into tItems
  repeat for each line tline in tItems
     if last char of tline is "/" then
        create folder "C:/Documents and Settings/max/Desktop/" & tline
        put "C:/Documents and Settings/max/Desktop/" & tline into temp
        revZipExtractItemToFile myzip, tline, temp
     end if
  end repeat
  revZipCloseArchive myzip
end mouseUp
Community content is available under CC-BY-SA unless otherwise noted.