Logo

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.

SET DEBUG, SET ECHO, SET STEP, SET TRBETWEEN, _Throttle, Set(“Debug”), Set(“Echo”), Set(“Step”), Set(“TrBetween”)

These items are all related to debugging, a necessary evil. They used to let you set up your environment to make debugging easier (or harder), but several of them are meaningless in VFP 5 and later.

Usage

SET DEBUG ON | OFF
cDebugFromMenu = SET( "DEBUG" )

In VFP 3 and earlier versions, SET DEBUG determines whether the Trace and Debug windows are available from the menu. In VFP 5 and later, SET DEBUG OFF is ignored—instead, the new DEBUG command controls the debugger.

SET(“DEBUG”) tells you the current setting of SET DEBUG.

Usage

SET ECHO ON | OFF
cEchoMode = SET( "ECHO" )
SET STEP ON | OFF
cStepMode = SET( "STEP" )

In VFP 3 and earlier, SET ECHO ON opens the Trace window without pausing; in VFP 5 and later, it’s ignored. SET STEP ON opens the Trace window and suspends execution of the program. SET ECHO OFF and SET STEP OFF don’t do anything.

SET(“ECHO”) returns “ON” when the Trace window is open, and “OFF” otherwise. SET(“STEP”) returns “OFF” regardless of the last setting of STEP.

The relationship between SET STEP and the Trace window is a little strange. Issuing SET STEP ON, whether in a program or from the Command Window, opens Trace and gives it focus. If a program is running, it’s suspended at the line following SET STEP ON. You can then use the MENU TO step through the code.

On the whole, it’s better to open the Debugger, set some breakpoints, and run an unmodified program than to insert SET STEP ON (or SUSPEND) in a program.

Usage

SET TRBETWEEN ON | OFF
cTraceBetween = SET( "TRBETWEEN" )

SET TRBETWEEN gives you programmatic control over the Trace Between Breaks setting in the Debugger. Issuing SET TRBETWEEN ON is the same as checking that item. In both cases, every line of the program is shown and highlighted when the Trace window is visible. With TRBETWEEN set to OFF or the item unchecked, no code is highlighted until a breakpoint is reached. Setting TRBETWEEN OFF executes the program faster, since no visual updates are needed.

SET(“TRBETWEEN”) tells you the last setting of SET TRBETWEEN. In VFP 3, it didn’t properly reflect changes made with the menu. Fortunately, this bug is fixed in later versions.

Usage

_THROTTLE = nStepSpeed
nStepSpeed = _THROTTLE

The _THROTTLE system variable determines how quickly a program executes when the Trace window is open. In some cases, especially if a program is making decisions based on keystrokes and mouse clicks, stepping through a program makes it too difficult to see what’s going on. Instead, it’s better to slow the program down so you can see what happens each step of the way. _THROTTLE lets you do that by specifying a delay of anywhere from 0 to 5.5 seconds between consecutive commands. In VFP 5 and later, of course, you can turn on Coverage and/or Event Tracking in the Debugger to get a log of what’s going on. Which tool is best depends on what kind of thing you’re debugging and what kind of problems you’re having.

You can set _THROTTLE programmatically or through the Throttle item on the Trace window’s context menu.

The setting of _THROTTLE is ignored unless the Trace window is open and Trace Between Breaks is ON.

Example

_THROTTLE = .5   && half-second between commands

See Also

Debug, Resume, Set, Set Coverage, Set EventList, Set EventTracking, Set Talk, Suspend