Hacker’s Guide to Visual FoxPro
An irreverent look at how Visual FoxPro really works. Tells you the inside scoop on every command, function, property, event and method of Visual FoxPro.
We hate hardware. Let’s get that one fact out from the beginning. IRQs and memory locations, obscure settings and incompatibilities are the bane of our existence. We’re FoxPro hackers, not wire weenies, and it saddens us that FoxPro requires any hardware at all—a virtual machine would be so much nicer to work on! However, this is the real world, and it’s a fact.
In the years since we first wrote this section for the Hacker’s Guide to Visual FoxPro 3, much has changed, and yet much remains the same. We’ve seen a number of flavors of Windows ship, from Windows 95 to the just-released (as of this writing) Windows XP.
“The faster and the bigger, the better” is a pretty good rule for FoxPro’s use of hardware. More CPU power and faster clock speeds mean faster performance; swifter video performance makes FoxPro shine; and a well-tuned operating system is icing on the cake. However …
Moderation in all things.
—Thornton Wilder, Our Town
A real fast processor isn’t worth much if it’s right only 98.997979% of the time. Blazing video performance that occasionally blazes into an inferno is useless. Whizzy new CD-ROMs ain’t worth a darn if they sometimes spit out your still-spinning disk when you need to read them. (Ted had a “compatible” machine that actually did this.) They don’t call it the “bleeding edge” for nothing. Unproven, version 1.0 technology is not the kind of thing that we bet the mortgage on, and you should probably consider these factors yourself. With proper backup and a consideration of the risks involved, investment in new technologies pays off for many hearty pioneers, but make sure when you’re purchasing hardware that there is a conscious decision when to buy a workhorse and when to buy a new thoroughbred colt.
It’s always something.
—Roseanne Rosannadanna
Our cut on things: Read the books, read the magazines, ask online. Make sure that what you’re purchasing is compatible, especially if a client is going to be running it.
At a minimum, Visual FoxPro claims it requires a Pentium processor and 64 megabytes of RAM. That’s pretty much the minimum configuration for Windows 2000, too, and Windows XP requires a Pentium or equivalent processor running at 300 MHz or better with 128 MB of RAM. Obviously, the faster the processor, the better the Fox will run. With machines available at 1 GHz and faster, it shouldn’t be difficult to find inexpensive hardware to develop on. As far as RAM goes, more is better. A minimum is 128 MB, though 256 MB gives good performance.
Your users might be able to get away with the minimum configuration, but be careful cutting corners. Test your app on one of their machines regularly to ensure that the app will run acceptably on their hardware.
You can never be too rich, too thin, or have too much hard drive space.
—Anonymous
Hard disk space is an issue for both developers and end users. A full installation of Visual FoxPro requires an enormous amount of space, easily half a gigabyte. Disk space is cheap; buy the biggest disk you can. Even a 10 GB drive on a laptop isn’t always roomy enough for a machine dedicated to FoxPro development. All that data to process can eat up space quickly!
One tip: If you’re installing the common components onto a FAT drive, each file will take up a minimum of one disk cluster. Clusters are sized based on the total capacity of the partition divided by 65535. So the bigger the partition, the more space is wasted for the dinky bitmaps, cursors and icons supplied with the package. Consider formatting the partition as FAT32 if you are running Windows 98, or using NTFS under Windows NT/2000/XP to minimize the wasted space.
A second hard disk issue you need to be aware of is that Visual FoxPro’s installation requires not only space on the volume where you want to install Visual FoxPro, but also free space on the drive where Windows is installed. Visual FoxPro comes with updated DLLs and Windows support files that will be installed in the main Windows and System subdirectories. These can take significant space. Obviously, overwriting these files will also require appropriate rights in the case of a network install.
In that same vein, use the Custom option of the Visual FoxPro install to determine which portions of Visual FoxPro may be reinstalled, uninstalled, or ignored. If you are installing workstation copies on multiple developers’ machines, you might want only the network administrative copy to be a full copy, while each developer can get by with a smaller subset.
For end users, besides the space for your application and its data files, you need to plan on over 4 MB for the runtime VFP7. files.
A good video card with plenty of resolution and memory is a necessity for working with Visual FoxPro. What with dozens of toolbars, as well as property sheets, tabbed options dialogs, drop-downs, OLE objects, OCX Outline controls and what-have-you, a powerful video card can make an enormous difference in your productivity. 256 colors is the minimum, with many running in High Color (24 bit) and True Color (32 bit) modes. The minimum resolution we’d even consider for running Visual FoxPro is 800 x 600, provided we’re working on a system designed for 640 x 480. A good working ratio is at least one resolution higher than the system being designed, and even better (given good eyes) is the highest resolution that the hardware will support.
Why one resolution larger than the screens you’re designing, you ask? It’s not too hard to place a full-sized 800 x 600 form on a 1024 x 768 screen, with enough room to access the necessary tools like the Property Sheet (about 200 pixels wide, placed to the side of the Form Designer) and the Command Window. On the other hand, if you try to edit an 800 x 600 form in an 800 x 600 mode screen, you’ll spend your life pushing scrollbars, moving dialog boxes, and cursing at Visual FoxPro. If you want to be able to interact with all parts of a form while you’re designing it, with the appropriate toolbars and property sheets also visible, you’ll want to use at least one resolution higher than you’re designing for (design “6 by 4” forms in “8 by 6”, design “8 by 6” forms in “10 by 7” and so on). Even better, design two resolutions higher: Design 800 x 600 forms in 1280 x 1024 . Stop us if you’ve heard this before—more is better.
While we’re on the subject of video, the monitor is the other element that makes a huge difference. 1024 x 768 or greater resolution is impossible to read (at least with our aging eyes) on a small 14” or 15” monitor. Seventeen inches is the least we’ll work on, and 19”, 20” or even 21” monitors make viewing an absolute pleasure. You’re going to spend an awful lot of your life in front of this tube—do yourself a favor and get the largest and clearest display you can afford. Even the new flat-screen monitors are coming down in price, and the benefit is that they don’t take up your entire desktop. For laptops, the newer 14.1” displays handle 1024 x 768 quite well.
A caution, however. While we feel that justifying the costs of a large monitor is a no-brainer for a developer, it may not be as easy for dozens or hundreds of operators using your application. Just as with processing speed, make sure that you check out your application frequently on one of the lower-powered, lower-resolution machines it will run on, to ensure that the interface is easy to use for the operators as well.
You have four choices for an operating system on which to run Visual FoxPro for Windows, and you shouldn’t be surprised that they all have the name “Windows.” They are Windows 98, Windows NT, Windows 2000, and Windows XP. We suppose you can add Windows ME, if you’re brave. Here are our somewhat biased opinions.
Windows 98 is looking more and more like a legacy operating system; however, you’ll find that many corporations are still running it. We wouldn’t want to develop on it, as it’s not as stable as its successors, but VFP runs just fine on it. Depending on your situation, it might still be your only option for the client operating system.
When Microsoft planned the FoxPro DevCon ‘95 in January, they hoped to show a late beta or perhaps even an early release copy of Visual FoxPro. Alas, a miracle did not come to pass, and instead they showed a late alpha/early beta copy of Visual FoxPro that crashed in nearly every session. But because they were running under NT, a simple double-click of the Visual FoxPro icon was all that was necessary to restart the app—NT cleaned up the mess very nicely, all by itself. That alone sold us. This is why we develop on Windows NT or a successor, because developers tend to try things that might (will?) crash their machines.
Windows NT is solid, but that robustness comes at a price. Performance is comparable to Windows 98 only on the higher-end processors, and NT demands more RAM than 98 (of course, as a developer, you’re hopefully running a higher-end machine). In addition, managing the Windows NT domain model, setting up security or maintaining a large network does not come easy. For more than a few machines, the assistance of a Microsoft Certified System Engineer becomes less of a luxury and more of a necessity.
One caveat—ensure that your machine is 100% NT compatible. This was more of an issue when we wrote the last edition of this book, but if you have clients running on old hardware, this can really bite you. The Hardware Compatibility List (HCL) is available from a number of Microsoft sources, and you should make sure that all of your peripherals are listed. Unlike DOS and earlier Windows incarnations, if it’s not listed, it probably won’t work. We’ve spent more than a few hours trying to shoehorn NT onto a machine that “should be” able to run NT, but some little part, perhaps a serial port or a video card, just wasn’t compatible enough. Don’t frustrate yourself. Only attempt upgrading to NT if the machine is really compatible.
Windows 2000 improves upon Windows NT. Of course, it needs a little more RAM, a little faster processor. But you get a little more stability, and a few more features. Performance is a little better (though booting still seems takes as long or longer than the other operating systems). Of course, none of your earlier Windows drivers will work on Windows 2000, so some older hardware is just not supported (nearly anything you buy today is supported), and upgrading a machine from 98, NT, or even ME can be an Internet scavenger hunt for drivers.
For a while, this was the operating system of choice to be factory installed on most new computers. Most developers immediately wipe it out to put on Windows 2000 (and then go on the Internet scavenger hunt for Win2K hardware drivers that don’t ship with the Windows ME machines). Windows ME was designed for home use, and incorporates lots of cool things like digital video, easy networking and lots of support for the Internet. Tight security and robustness was not a part of this operating system’s design.
Windows XP comes in three flavors: the Home edition, the Professional edition, and a special 64-bit version for technical workstations (we don’t think you’ll see that one too much). Windows XP launched on October 24, 2001, while we were writing this book. Some people love the new features, one of which is ClearType for LCD screens, which makes 1600 x 1200 very readable on a 15” notebook display. It also is supposed to be “crash-free” (yes, they really say that on their Web site), and has plenty of support for huge hardware configurations.
There’s one real drawback. It’s called Windows Activation. This is Microsoft’s brilliant scheme to prevent softlifting, or software piracy. Upon installation, after typing in the product key, you’re assigned an installation ID. It’s based on information about the hardware configuration being passed into a one-way hash, and coming up with the installation ID. (Microsoft guarantees this ID contains no private information.)
This installation ID is automatically sent to Microsoft if you have an Internet connection or modem; otherwise you must call it in within 30 days or only the activation portion of the operating system will work. Successive installations for this product key calculate the installation ID, and if the hardware is identical or “similar” (as in, you’ve added or removed some hardware), XP will activate again and run just fine. It will squawk only if the hardware is substantially different.
Developers swap out hardware with incredible frequency, sometimes swapping out enough hardware to make it look like a different machine. Microsoft’s answer is that you simply need to call and get another installation ID, and you’re on your way. Not something we’d like to do several times in a week for testing various hardware, or several times between 1 and 3 a.m. (the best hours for development).
No doubt, someone’s out there, even as you read these words, oh, faithful reader, picking up their poison pen to write us a flaming, screaming, bombastic letter on how we have ignored the most powerful operating system in both the known and unknown universes: (fill in the blank). This next paragraph is for them. You can skip it.
We know. It’s not our fault. VFP 5.0 and later run on 32-bit Windows and that’s all. No dice. Sorry. Call Microsoft.
We do call this section “Recommendations,” so we should name our operating system of choice. Well, life is not always that easy. Della runs Windows 2000 Professional, and has one machine that dual boots into Windows 98 for testing (and for some old software and hardware that isn’t supported by Win2K). Doug runs Windows 2000 Server, and likes it, although he pines for the DOS days every time he waits for it to restart (ain’t that the truth!). Tamar also runs Windows 2000 Professional on her development machines. Her test machine runs NT4, but soon it may be upgraded to Windows XP, in her elusive free time. Noted for liking the simplicity of running the same operating system on all machines, she’s feeling a little less stubborn about it these days. Ted runs a heterogeneous network of Win2K Pro (x3), WinNT 4.0 Server (IIS and SQL Server Development), Win2K Server (Intranet), Win95 (one print server, one utility terminal), and Win2KPro on two laptops.
So what should you choose?
It does depend to some extent on your client base: If they are all running Windows 9X (or NT), you probably should be, too, or at least have one machine available and used regularly that squawks if you are writing software your clients can’t run.
For a development machine, Windows 2000 wins hands down. Win2K Professional works fine if licensing is a problem.
What about Windows XP? As we’ve shown you, none of us have upgraded to WinXP yet. Why? It probably has something to do with it shipping while we were writing this book, and every experienced developer knows not to change the configuration of a working development machine in the midst of a project. It also has to do with the experienced developer’s wait-and-see attitude of hearing the experiences of other developers who like to live on the edge. We’ve heard things ranging from “VFP runs the best on WinXP,” to “XP is a bad nightmare added on to Win2K, primarily an advertisement for Microsoft services like MSN, Messenger, Media Player and Passport.” It’s new enough that it hasn’t really proven itself in the marketplace yet. Few corporations seem to find a compelling reason to upgrade. But they will, ‘cause Microsoft ain’t shipping anything else. We’re all cautious, waiting until at least the first Hot-Fix or Service Pack, which, as of this writing, hasn’t happened yet.
BUT, if your new whiz-bang box comes from the manufacturer (OEM) with Windows XP on it, you’ll likely want to stay with it. Microsoft and their hardware vendors are constantly innovating new standards, and you’ll find that new machines may be incompatible, or they won’t have drivers for legacy (last week’s) operating systems. Stick with WinXP if you get it. If you get WinME or Win98SE from the manufacturer, you could be in for compatibility nightmares—or at the very least, an Internet scavenger hunt trying to find drivers. (Della’s laptop, shipped with Windows ME, needed nine separate files from several Web sites, and 26 reboots to install them, to get to Win2K compatibility.) Insist on Win2K or WinXP from the factory.
If you’ve run computers for a while, you recognize they need regular maintenance. The case needs to be opened yearly and the dust blown out. Backups should be done regularly to prevent loss in case of hardware failure (“regularly” means daily to weekly, not quarterly to annually). Hard disks need to be defragmented—perhaps weekly. Directories storing temp files should be purged. But here’s one you may not have considered:
Format your hard drive regularly.
“What!?” you scream. “It took me days to install all this stuff and now you want me to blow it all away?”
Yup. The Freeman treatment (named in honor of Dan Freeman, a Prince Among Men, and guru extraordinaire) is the only reliable cure we’ve found for all those little aches and pains: The Registry that just doesn’t seem right anymore. The weird DLLs with names you can’t fathom. The bloat of the System directory to hundreds of megabytes.
Blow it all away.
Radical as the idea seemed to us at first, it does make some sense. Developers who install, test and remove a bunch of stuff from their machines are likely to get machines that bog down after a while. Downloading lots of goodies from the Internet and installing beta packages ensures that some “stuff” gets left lying around on your hard drive. Finally, the occasional misbehaving application will overwrite a key system file with an older or less stable one, and that’s it—you’re out of business.
But doesn’t that take a lot of time? Sure. But utilities like Ghost or DriveImage make this process much less painful. First, get a good installation (maybe the one that came from the manufacturer), and make an image. Then, install all the software you need. Make another image. Don’t forget all the tools you can’t live without (WinZip comes to mind). Maybe even a couple more iterations. Then, when Freeman day comes, you don’t really reformat the hard drive; instead, you restore the appropriate image, then install whatever else you need to, and find your data backups (which not only include your development work, but also extremely important data like your address book and Internet bookmarks). Plan for the inevitable. Log the files you install on your machine. Keep a network directory available with the “goodies” you can’t live without. Get a serious backup device for the stuff you need to restore regularly: digital tape, ZIP, Jaz and SysQuest are worth considering. Archive the CDs with your key development tools on them. And, of course, make lots of backups.