Article ID: | qGEN009 |
Date Revised: | July 28, 2000 |
Keywords: | DEBUGOUT, VFP5 Debugger |
See Also: | Download debstr.prg (1KB) |
Question: How can I get around the limitation that DEBUGOUT only takes a single item as it's eExpression?
Answer: The VFP5 debugger is a vast improvement over the tools that were in earlier versions of FoxPro. DEBUGOUT, one of the new commands in VFP5, is a much more useful debugging tool than WAIT WINDOWs or using ? to output trace and debug information. It provides a scrollable window that contains all of the output sent to it. The information in the window can be copied and pasted to another file which is handy trying to compare the differences between two complex sequence of events. It also has the benefit of being invisible unless the Debug Output window is visible.
I wrote this little UDF that takes up to ten arguments and build a single string to use with the DEBUGOUT command.
Usage:
debugout debstr( nItem1, cItem2, dItem3 )
* debstr.prg 13-Jul-97 * This function takes various type args and converts to a string for debugout * 28-Jul-00 restructured to use transform * NOTE: for VFP5 the second argument to transform was required * you can use "" for it lparameter p1, p2, p3, p4, p5, p6, p7, p8, p9, p10 local i, lcRetVal, lpX lcRetVal = "" for i = 1 to pcount() lpX = eval( "p" + alltrim( str( i ) ) ) do case case type( "lpX" ) == 'C' lcRetVal = lcRetVal + [ "] + lpX + ["] otherwise lcRetVal = lcRetVal + " " + transform( lpX ) endcase endfor return lcRetVal
TIP if you want to log notes about what was going on at the time just do a DEBUGOUT "I just pressed the save button and the form crashed" in the command window.
TIP the debug output window can be displayed with ACTIVATE WINDOW "DEBUG OUTPUT" which can be handy if you've got a block of code that's about to use DEBUGOUT you can just include the ACTIVATE in your code so the output will be captured.