DebugOut, Set DebugOut, Set("DebugOut")

So how do you figure out what's going on in a particularly knotty piece of code when it doesn't do what you want? You might step through it, but sometimes the mere act of stepping through code changes the results. Often, you sprinkle it with messages that tell you what's going on at various points in the code so you can see what's happening without changing the results. These commands make that task much easier.

Usage

DEBUGOUT uExpression
SET DEBUGOUT TO  [ FileName [ ADDITIVE ] ]
cDebugOutFile = SET("DEBUGOUT")
DEBUGOUT lets you send any message you want from your code to the Debug Output window of the debugger. You can pass it data of any printable type, even memo fields, and it handles it correctly. DEBUGOUT is a much better choice than the WAIT WINDOWs we're all accustomed to using. By its very nature, WAIT can change the timing of activities in your code. The only thing DEBUGOUT does is take a tiny, tiny chunk of time to send the data you pass it along. Best of all, you don't even really have to pull DEBUGOUT statements out of your code. If the Debug Output window isn't available (either because it's closed or because you're running the runtime), the output just goes into the bit bucket.SET DEBUGOUT lets you send the output to a file as well as the Debug Output window. (Actually, if the debugger is closed, the redirected output goes only to a file.) Just specify a filename and VFP happily sends anything that's going to the Debug Output window to that file as well. Include ADDITIVE to continue an existing file. Issue SET DEBUGOUT TO with no filename to close the current output file.One warning here: VFP empties the specified file as soon as you issue SET DEBUGOUT, not the first time you put something in. So make sure you have the right filename before you press Enter.SET("DEBUGOUT"), of course, tells you the name of the current debug output file.There's one other point worth noting. The Debug Output window actually receives more than just DEBUGOUT statements. Assertion messages and any events being tracked land there, too, and are placed in the specified file, as well.

Example

SET DEBUGOUT TO Whatgives.Txt
DEBUGOUT "See, this goes to the window and the file"
ASSERT .F. MESSAGE "Yuck!"
DEBUGOUT "You can send any type like this:"
DEBUGOUT DATE()
DEBUGOUT TIME()
DEBUGOUT 42

See Also

Assert, Debug, Set EventTracking, Wait


Back to Table of Contents

Copyright © 2002-2018 by Tamar E. Granor, Ted Roche, Doug Hennig, and Della Martin. Click for license .