This blog entry is going to be quick because it is going on 4:30 AM at this end. If I don’t get some sleep, the shadow people will be coming to take me away! Even though sleep deprivation has become a way of life at this end, I try not to over do it for obvious reasons.

Wash, Rinse, and Repeat
I’ve always thought it would be cool if Visual FoxPro had its own compression functions. The ability to generate Zip-compatible files and unzip said same is one of the things that many developers do in their applications over and over again. In the case of Visual FoxPro, adding compression features has usually been a matter of finding some 3rd party product that provides the needed functionality and then wrapping it using Visual FoxPro classes and/or code.

Half-baked Extended MAPI FLL and Zlib
Well, for a few weeks now I’ve been thinking that I needed to come up with something cool to make up for the lack of blog entries here on the SPS Weblog. I’ve thrown down some code for another FLL that aims to give VFP’ers Extended MAPI support (I’d like to say goodbye to Outlook Security warnings for VFP applications among other things), but I’m not quite done with that one. Soooooo, given that zlib compression library is freely available, and there are quite a few C++ wrappers out there that work with it (regrettably most are MFC), I thought I would sit down for a few hours and write an FLL that would allow the VFP Community to work with Zip files natively.

Download Link and Sample Code
Before downloading this FLL please bear in mind the following..

  • there are a lot of functions in this FLL that are not shown in the code below
  • I don’t have time at the moment to document this whole thing (I’ll be back later – promise)
  • this hasn’t been tested very thoroughly (moving from Alpha into Beta on it at the moment)
  • the vfpcompression.fll was compiled with VS2003, so the only dependency should be msvcr71.dll which is a VFP 9.0 runtime anyways (references to MSVCP71.dll have been removed)
  • I will be producing a VC++ 8.0 version of this also, but that’ll come later – and yes, I’ve changed my mind and when possible I will provide both 7.1 and 8.0 versions of the FLLs I create
  • ideas and suggestions for functionality/improvements are welcome (I’m already working on a couple of string compression functions for this and as I said, there are a lot of functions that the code below doesn’t touch on)

That having been said, here’s the download link and a few simple code examples to get you started…

VFPCompression FLL Download (32 KB approx.)

*!* Example 1
SET LIBRARY TO LOCFILE(“vfpcompression.fll”)
    ?ZipOpen(“C:\”, “C:\”, .F.)
    ?ZipFile(“C:\SomeFile.txt”, .F.)
    *!* could zip other files and folders here before close

*!* Example 2
SET LIBRARY TO LOCFILE(“vfpcompression.fll”)
    ?ZipOpen(“C:\”, “C:\”, .T.)
    ?ZipFolder(“C:\SomeFolder”, .F.)
    *!* could zip other files and folders here before close

*!* Example 3
SET LIBRARY TO LOCFILE(“vfpcompression.fll”)