Create a bzip2 or gzip file

Added by iNTERFACEWARE

How to create and unzip a bzip2 or gzip file, using filter.bzip2.deflate() and filter.bzip2.inflate() or gzip.deflate() and gzip.inflate()

Source Code
   -- create a bzip2 file from a string

   -- construct a test string to be compressed
   local  S = 'Replace this string with your own data, or read it in from a file'
   trace(S)
   
   -- gzip the file into a string
   local zip = filter.bzip2.deflate(S)
   trace(zip)
   
   -- unzip the file from the string
   local unzip = filter.bzip2.inflate(zip)
   trace(unzip)
   
   -- save the file to disk 
   local f = io.open('test_bzip2.zip', 'w')
   f:write(zip)
   f:close()
   
   -- go to the Iguana home directory and run 'test_bzip2.zip'
   
   -- create a gzip file from a string
   
   -- gzip the file into a string
   local zip = filter.gzip.deflate(S)
   trace(zip)
   
   -- unzip the file from the string
   local unzip = filter.gzip.inflate(zip)
   trace(unzip)
   
   -- save the file to disk 
   local f = io.open('test_gzip.zip', 'w')
   f:write(zip)
   f:close()
   
   -- go to the Iguana home directory and run 'test_gzip.zip'
Description
How to create and unzip a bzip2 or gzip file, using filter.bzip2.deflate() and filter.bzip2.inflate() or gzip.deflate() and gzip.inflate()