There's tremendous excitement in the VFP community since Microsoft took the wraps off Visual FoxPro 8 at Visual FoxPro DevCon 2002 in Ft. Lauderdale. The general sentiment is that VFP 8, expected to be released early next year, represents the most significant upgrade since VFP 3.
In the August issue, I wrote about the features of VFP 8 that were public then. Here I give you a look at more features.
Easier handling of remote (and native) data
Two new classes, as well as changes to some existing classes, make it easier to work with data. The new CursorAdapter class provides a uniform interface for all kinds of data, both remote and local. You fill in properties that specify how data is to be retrieved and updated, and then a single method call creates and populates a VFP cursor. This means that when the back end for your application changes, all you have to change are some properties. The rest of your code works as always.
The XMLAdapter class makes it easier to work with hierarchical XML data, including Visual Studio .NET datasets and diffgrams. XMLAdapter uses two more classes, XMLTable and XMLField.
VFP 8 lets you subclass the DataEnvironment class (even visually), and then attach your subclasses to both forms (.SCX) and form classes (.VCX). The Cursor class can also be subclassed. So you can create a single data environment and use it with multiple forms. With the new subclassing ability, you can also add custom code to cursors and data environments, and know that it's used across the board.
Two new builders support all this: DataEnvironment and CursorAdapter.
There are a few other data-related changes (in addition to the ones I mentioned in August). Queries with the UNION clause now perform some type conversion, so you can, for example, pair a character field and a memo; the result uses a memo field in that position. When two matched fields are the same type but different lengths, VFP 8 chooses the larger size for the result field.
There are two extensions to the SQL INSERT command. INSERT INTO ... FROM NAME lets you add a row to a table with data from an existing object. INSERT INTO ... SELECT lets you add multiple rows based on the result of a query. The SCATTER NAME command has a new ADDITIVE clause that lets you add properties and data to an existing object.
Structured error handling
The TRY ... CATCH ... FINALLY structured error handling mechanism lets you deal with errors locally, and makes it easier to clean up when they occur. You put code that might fail in the TRY block, and then use one or more CATCH blocks to handle errors that occur. The FINALLY block contains code that should be executed whether or not an error occurs.
Along with this statement, when an error occurs in a TRY block, a new Exception object is populated with details about the error. The THROW command lets you escalate an error to a higher-level TRY structure.
Event binding
VFP 7 gave us the ability to bind VFP code to COM events (through the EventHandler() function). VFP 8 goes a step farther and lets us bind code to VFP events with the BINDEVENTS() function. Why would you bind one method to another event rather than just calling the method? The most obvious case is when you're dealing with code you can't change or subclass, such as a third-party tool.
RAISEEVENT() is a new function that lets you trigger an event. When you call the method associated with an event, the method code runs, but the event doesn't fire. RAISEEVENT() fires the event, too.
New tools
In addition to the new builders, VFP 8 contains several new tools. The Toolbox feels like a marriage between the Form Controls toolbar (which it's intended to replace) and the Component Gallery. It's far more capable than the toolbar, but much easier to use and understand than the Gallery. You can customize it to include the classes you work with regularly, and in fact, it can also hold pieces of text or pretty much anything else.
The Task Pane Manager gathers everyday tasks in one place. It comes with a variety of "task panes," pages that group related tasks together. One pane contains links to a variety of VFP support sites. Another pane is an Environment Manager, where you can specify a group of environmental settings and the projects to which they apply. It includes several other panes as well.
The new Code References tool lets you search for a string in a project or folder (including subfolders). Choosing an item from the list of matches opens the appropriate editing tool.
And there's more...
There's a lot more, including reporting improvements, but I've run out of space. We'll cover VFP 8 features in depth in coming issues, so stay tuned.
If you agree that the Microsoft Fox team has outdone itself with Visual FoxPro 8, the best way you can tell them is to upgrade as soon as the product becomes available.