# Friday, September 29, 2006

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:\MyZipFile.zip", "C:\", .F.)
    ?ZipFile("C:\SomeFile.txt", .F.)
    *!* could zip other files and folders here before close
    ?ZipClose()
SET LIBRARY TO

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

*!* Example 3
SET LIBRARY TO LOCFILE("vfpcompression.fll")
?UnzipOpen("C:\MyZipFile.zip")
?UnzipTo("C:\")
?UnzipClose()
SET LIBRARY TO

Friday, September 29, 2006 10:52:04 AM (GMT Daylight Time, UTC+01:00)  #    Comments [7]
Friday, September 29, 2006 7:41:42 PM (GMT Daylight Time, UTC+01:00)
Hi Craig,

Looks cool, but I couldn't get it to work. ZipOpen() and ZipClose() appear to work, but ZipFile() and ZipFolder() are only returning .F. for me.
Mike Potjer
Saturday, September 30, 2006 1:03:09 PM (GMT Daylight Time, UTC+01:00)
Craig,

This statement has me smiling profoundly:

"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."

None of the well-known alternatives (http://www.tek-tips.com/faqs.cfm?fid=1856 or the VB-based ClickYes app.) to bypass the dreaded Outlook warnings are entirely satisfying for a number of reasons.

I have not yet tested the new VFP Compression FLL but it is also good thing! I agree it is a good idea to publish these contributions with a sole dependency on msvcr71.dll to simplify distribution/implementation of VFP 9 apps.

Kenneth Tamayo
San Juan, Puerto Rico
Saturday, September 30, 2006 2:08:28 PM (GMT Daylight Time, UTC+01:00)
Very nice! I wish I had the knowledge to write C flls and dlls for VFP.

Are you planning on adding some way of showing progress to the user?

One simple way maybe is for the fll to update a _Screen.ZipProgress property value, or make the property name selectable, then we can bindevent to it, and show a progressbar or whatever.
Carlos Alloatti
Saturday, September 30, 2006 11:33:16 PM (GMT Daylight Time, UTC+01:00)
Hi Craig,

Got the same urge for a VFP zip/unzip utility a while back and did a wrapper for the open source Info-Zip libraries. Here's a link to the installer: www.ssltdata.com/ftp/foxzip_setup.zip. Works but I'm still calling it a Beta.

Source code is included with the installer so maybe it can provide some ideas, if nothing else. It does use a couple of other resources (included). I like your idea of a single FLL much better.
Sunday, October 01, 2006 1:58:13 AM (GMT Daylight Time, UTC+01:00)
Mike,

Can you try the latest version of the FLL and see if it works for you? It is available (along with documentation) in my next blog entry. Let me know.

Kenneth,

Thanks for the kind words and I look forward to completing the VFP Extended MAPI FLL soon. I now agree with most dev's assertions that a dependency to msvcr71.dll is optimal for VFP 9.0 development. Unfortunately the vfpencryption71.dll also has a dependency on msvcp71.dll which I haven't found time to remove yet.

Carlos,

I will be adding a Progress callback to the FLL that VFP devs can set to a function, procedure or method in VFP. See the list of possible future features for this FLL in my next blog entry. I like the way you think.

Sam,

Thanks for the kind words and the information regarding foxzip, I'll check it out. Can you take a look at the functions that the vfpcompression.fll currently has (next blog entry here) and the list of possible future features and tell me if there is anything that sticks out at you as missing here?
Monday, October 02, 2006 5:21:36 AM (GMT Daylight Time, UTC+01:00)
Craig,

QUOTE: I've changed my mind and when possible I will provide both 7.1 and 8.0 versions of the FLLs I create.

THANK YOU - THANK YOU - THANK YOU!!!

Regarding vfpcompression enhancements:

1. Can you combine the progress, status, and cancel callback functions into a single callback function that gets called after every file gets processed during a zip/unzip operation? If your callback function returns a file name, operation code, and before and after zip/unzip file sizes, then a developer can update status messages, progressbars, and check for cancel events. If your code checks its callback function for return values, then a developer can return a cancel code when they need to cancel an operation.

2. For security: support for zip compatible passwords/encryption would be sufficent. If one needs a more secure form of encryption, they can always use your companion vfpencryption.fll for the ultimate in encryption capabilities :)

3. I would rate self-extracting zips and disk spanning as very low priority features. Most of my clients won't touch self-extracting zips (they want to know what's in a zip file and they want to be able to customize what and where they extract to) and exe files don't email well. Regarding disk spanning: with CD's and DVD's so common-place today, I'm hard pressed to find a real need for disk spanning.

Thank you for your contributions to the VFP community, er, I mean the VFP World Domination Tour!

Malcolm
Tuesday, March 20, 2007 7:23:37 PM (GMT Standard Time, UTC+00:00)
This looks nice but when I try to run on VFP 8 it returns .F. for everything

Do I need any dependencies installed?

Thanks
cdfornal
All comments require the approval of the site owner before being displayed.
Name
E-mail
(will show your gravatar icon)
Home page

Comment (Some html is allowed: a@href@title, b, blockquote@cite, em, i, strike, strong, sub, sup, u) where the @ means "attribute." For example, you can use <a href="" title=""> or <blockquote cite="Scott">.  

Enter the code shown (prevents robots):

Live Comment Preview

 

Archive

<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789