A handle that lets ABL procedures initialize and control the Application Debugger.
To use the DEBUGGER handle, you must have the Application Debugger installed in your OpenEdge environment.
The following example displays Orders for each Customer in the Sports2000 database using two procedure files. The r-cusbug.p file initializes the Debugger and sets a breakpoint at line 6 of the r-ordbug.p file. Thus, each time r-ordbug.p displays an Order, the Debugger takes control before it displays the Order Lines. Just before completing execution, r-cusbug.p clears the debugging session before returning.
r-cusbug.p
DEFINE NEW SHARED BUFFER CustBuf FOR Customer. DEFINE VARIABLE debug AS LOGICAL NO-UNDO. debug = DEBUGGER:INITIATE(). debug = DEBUGGER:SET-BREAK("r-ordbug.p",6). FOR EACH CustBuf NO-LOCK: IF CAN-FIND(Order OF CustBuf) THEN RUN r-ordbug.p. END. debug = DEBUGGER:CLEAR(). |
r-ordbug.p
DEFINE SHARED BUFFER CustBuf FOR Customer. FOR EACH Order OF CustBuf NO-LOCK: DISPLAY CustBuf.Name CustBuf.CustNum CustBuf.City CustBuf.State CustBuf.PostalCode Order.OrderNum. FOR EACH OrderLine OF Order NO-LOCK, Item OF OrderLine NO-LOCK: DISPLAY Item.ItemName Item.ItemLum LrderLine.Qty. END. /* FOR EACH OrderLine */ END. /* FOR EACH Order */ |
The DEBUG( ) and INITIATE( ) methods provide separate means to invoke the Debugger, and do not depend on each other to start a debugging session. The DEBUG( ) method initializes and gives control to the Debugger whether or not the INITIATE( ) method has been executed.
1 DEFINE VARIABLE lStart AS LOGICAL NO-UNDO INITIAL TRUE. 2 PROCEDURE ShowStart: 3 IF lStart THEN MESSAGE "Procedure is starting ...". 4 END. 5 6 MESSAGE "Hello World!". 7 RUN ShowStart. 8 lStart = FALSE. . . . |
If you specify a breakpoint at line 0, -1, or any negative value, the breakpoint actually occurs at line 6, the first line that executes in the main procedure. If you specify a breakpoint at line 1 or 2, the breakpoint occurs at line 3, the first executable line in the file, which happens to be the first executable line of an internal procedure.
This distinction also affects procedures containing the Trigger phrase used to define triggers in widget definitions. For example, suppose procedure specifies this file:
1 DEFINE BUTTON bOK LABEL "OK" 2 TRIGGERS: 3 ON CHOOSE 4 MESSAGE "OK Pressed!". 5 END TRIGGERS. 6 MESSAGE "Hello World!". . . . |
Again, if you specify a breakpoint at line -1, the breakpoint occurs on line 6, but if you specify the breakpoint at line 1, it actually occurs at line 4, which is the first executable line of a trigger block.
For more information on the Debugger, its features and functions, and its modes of execution, see OpenEdge Development: Debugging and Troubleshooting.