KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using the 4D v11 SQL Pasteboard as a Debugging aid
PRODUCT: 4D | VERSION: 11.4 | PLATFORM: Mac & Win
Published On: August 6, 2009
Your current browser may not allow you to download the asset. We recommend Mozilla Firefox or Google Chrome.
Log In

It is very helpful to determine what is being passed without having to step through the debugger. In compiled code the debugger isn't an option. The 4D v11 SQL Pasteboard can be a handy debugging aid.

Below is a simple method that can be added to a database to implement use of the SET TEXT TO PASTEBOARD command in debugging. Pepper calls to this method in spots of interest in your code. It can be turned on and off by a Boolean interprocess variable, <>Debugging_B. Place calls to it in places of debugging interest and after the run, go to your favorite text editor and "Paste" the text in. There you have a quick and easy debug trace log.


`UTIL_PasteboardDebugLogger ($Caller_T;$Action_T;$TextToPaste_T)

C_TEXT($Caller_T;$1)
C_TEXT($Action_T;$2)
C_TEXT($TextToPaste_T;$3)
C_TEXT($Buf_T)

If (<>Debugging_B) `// Make sure this boolean is defined early in the application
    
    $Caller_T:=$1
    $Action_T:=$2
    $TextToPaste_T:=$3
    
    `======================== Method Actions ==================================
    
    If ($Action_T="Append")
        $Buf_T:=Get text from pasteboard+"\r\r"
        $Buf_T:=$Buf_T+$Caller_T+": "+$TextToPaste_T
        SET TEXT TO PASTEBOARD($Buf_T)
        
    Else
        CLEAR PASTEBOARD
        SET TEXT TO PASTEBOARD($Caller_T+": "+$TextToPaste_T)
        
    End if
    
    `======================== Clean up and Exit =================================
    
End if



To test, run the following code and then "Paste" into your favorite text editor.


C_TEXT($MethodName_T)
$MethodName_T:=Current method name
C_BOOLEAN(◊Debugging_B)
◊Debugging_B:=True

UTIL_PasteboardDebugLogger ($MethodName_T;"Paste";"This is paste #1")
UTIL_PasteboardDebugLogger ($MethodName_T;"Append";"This is paste #2")
UTIL_PasteboardDebugLogger ($MethodName_T;"Append";"This is paste #3")

Commented by Jesse Pina on September 4, 2009 at 12:58 PM
It can also be useful to add code to write this information to a file. This can be helpfull in situations where you want to track the debuging information, but will not be accessing the database till a later date.