Execute Selection in VFP

If you're a VFP developer, you probably already know you can run a line or lines of code in the Command window by selecting them and choosing Execute Selection from the shortcut menu. But did you know you can do this in a VFP editing window, too?

This can be useful for testing selected chunks of code during development, but it also gives you a VFP equivalent to the SQL Server Query Analyzer. In SQL Server, you can store several batches of T-SQL statements in a single query file and run them independently of one another using the Query Analyzer. In VFP, you can store several groups of SQL statements in a single program file and run them independently of one another using the Execute Selection command in a VFP editing window.

As in the Query Analyzer, you can revise the code in the VFP editing window and execute it without having to save the file. Unlike the Query Analyzer, though, the F5 key does not execute the selection in a VFP editing window. Neither does VFP recognize the GO command that signals the end of a batch in the Query Analyzer (GO has a different meaning in VFP); if you need a way of ending a batch of statements in VFP, use RETURN.

SQL Server 2000 Query Analyzer VFP 9.0 SP1 Editing Window

VFP's Execute Selection feature can be useful during development and testing of almost any kind of VFP code, but it's particularly handy when you're working with lengthy SQL statements. While you could use the VFP Command window for the same purpose, an editing window is much more usable when individual statements run into several lines of code, which is typically the case with SQL statements. A program file is of course also more useful than the command window when you want to save your work and return to it later.

VFP 9.0 Editing Window

07/12/2006 - Republished this post with corrected image and text layout.

Tags: , , ,


Garrett said...

I don't see the pictures, but you might be able to get rid of the problems by turning off the "Enable float alignment" option in Blogger.

Rick Borup said...

The problem was the links to the images. They were relative to main blog page, which doesn't work when the individual post is viewed from its archive location. The images should show up now when the post is viewed from either location.

Garrett said...

*rolls eyes* Yup, made that mistake too, on a regular basis...