Visual FoxPro 8

VFP 8 has introduced a number of deep and useful enhancements to the language. I'm sure that things like the improved error handler, the BindEvent function, and the CursorAdaptor class are going to be very useful in the future but these notes are just the results of a few hours' experimenting with the VFP 8 Beta release. From what I've seen so far, I like it.

Browse Window

Two small but welcome additions to the Browse Window that make the user interface a little more like what we are used to in similar situations in Access and Excel:

  • CTRL+HOME and CTRL+END now behave just as they do in every other Windows application - they take you to the top and bottom of the browse window.

    I'm sure I can't be the only developer who has had to code something like:
    ON KEY LABEL CTRL+HOME GO TOP
    in order to make Fox behave like every other Microsoft tool so I'm pleased to see this.
  • If you double-click a browse window in the header on the border between two fields then the column will autosize to the width needed by the longest field. You can get this behaviour in a grid as well by using AllowAutoColumnFit and AutoFit.

Code Window

The View Definition and Look Up Reference commands are going to be really useful. Both are on the Tools menu and on the shortcut menu for any code editor window:

View Definition

This is similar to the Definition option in Access. If the cursor is on a user-defined procedure or function then this will open a code window showing the definition of that routine.

If there is more than one possible definition, for example if you have alternate versions of the same routine in two different procedure files, then a Goto Definition window appears so that you can choose. If the cursor is over a FoxPro word then VFP Help opens on that entry.

Look Up Reference

This is the inverse of View Definition and shows you where a function or variable has been used in the project. It is similar to the XRef report in the Documenting Wizard but it's interactive.

The two of these form a powerful combination for maintenance work. I am in the process of extending somebody else's (undocumented) project and have had to be very careful of making changes that have unwanted side- effects. Using View Definition in VFP 8 I can quickly find the source code of an unknown routine and then Look Up Reference shows me where else this routine is being used.

The most powerful - and the most frightening - feature here is the ability to do a search-and-replace across the project. Ever so useful when you realise that a field name has to be changed.

Data handling

The most useful enhancements here are:

  • A new AutoInc field type that automatically increments to give us unique ID numbers in the same way as Access and SQL Server. The good news is that VFP 8 gives us control over the starting value and can change an existing integer field into an incrementing one. The bad news is that a table having this new type of field can't be opened in VFP 7 or any earlier version of FoxPro.
  • SQL UNIONs are now easier because VFP 8 does some type conversion for us. For example, a union of an INTEGER field with a REAL would fail in VFP 7 with the error message: 'SELECTs are not UNION compatible'. Visual FoxPro 8 will do an implicit conversion and generate an output set of REAL. Similarly with strings of differing lengths, VFP 8 will save us having to pad the length of the shorter field.
  • We can now export 65,000 rows to an Excel spreadsheet rather than the old limit of around 16,000.

Puzzle

[Puzzle in VFP8] Younger readers may not remember that early versions of FoxPro included a puzzle. It used to be the last entry on the Help menu in Fox 2.5 and 2.6 but disappeared from the menu when Microsoft launched Visual FoxPro.

The puzzle was still available from the Command Window for a little while but in VFP 6 it vanished altogether. It's back in VFP 8 if you enter:

ACTIVATE WINDOW puzzle

in the Command Window.

The aim of the game is to rearrange the blocks into numerical order by moving a block into the space. Click on any one of the blocks around the space to slide it into the space. You can also slide a row or column of blocks by clicking on the block at the other end - click on 11 or 15 here to move the whole vertical or horizontal line of blocks.

Press CTRL-END to cheat.

Nice to see an old friend back but one has to wonder at the commercial justification within the FoxPro development team for the effort of reinstating it.