Release 10.1A: OpenEdge Development:
Debugging and Troubleshooting

> ## Using the DEBUGGER system handle in stand-alone mode

> This technique is useful for running the Debugger as a tool started from one application to debug other applications. The invoking procedure runs the Debugger much like a subroutine, but it does not specify any procedure for the Debugger to run as its initial current procedure. You must run all procedures you want to debug from the Debugger after it starts by using the Run option on the Debug menu.

> ##### Invoking the Debugger as a tool of your application

> | To start the Debugger from the 4GL while blocking the invoking procedure:

> 1. Optionally, add a `DEFINE` `VARIABLE` statement that defines a logical variable you can use to assign the return value for the `DEBUGGER` system handle method.

> 2. Add a `DEBUGGER` system handle statement that invokes the `DEBUG( )` method at the point where you want to start the Debugger.

> In the following example, the procedure presents four execution options. The first three options invoke procedures. The fourth option invokes the `DEBUG( )` method and blocks at the following statement (line 33) while the Debugger runs:

>             1   DEFINE VARIABLE procname AS CHARACTER EXTENT 3.
>             2   DEFINE VARIABLE programNum AS INTEGER INIT 1
>             3      VIEW-AS RADIO-SET
>             4      RADIO-BUTTONS "Customer Report", 1,
>             5                    "Order Report", 2,
>             6                    "Item Report", 3,
>             7                    "Other", 4.
>             8   DEFINE BUTTON runReport LABEL "Run Report".
>             9   DEFINE BUTTON done LABEL "Done".
>            10
>            11   /* Initialize the list of procedure names to be run */
>            12   procname[1] = "custrpt.p".
>            13   procname[2] = "ordrpt.p".
>            14   procname[3] = "itemrpt.p".
>            15
>            16   DISPLAY "R E P O R T I N G   S Y S T E M" SKIP(1)
>            17            WITH COLUMN 18 NO-BOX.
>            18     FORM
>            19       SKIP(1) space(1) programNum
>            20       SKIP(1) SPACE(1) runReport SPACE(2) done SPACE(1)
>            21       SKIP(1)
>            22       WITH FRAME mainMenu
>            23       COLUMN 21 NO-LABELS
>            24       TITLE "M A I N   M E N U".
>            25
>            26     ON 'choose':U OF runReport IN FRAME mainMenu
>            27     DO:
>            28       ASSIGN programNum.
>            29       IF programNum < 4 THEN
>            30           RUN VALUE(procname[programNum]).
>            31       ELSE
>            32           DEBUGGER:DEBUG().
>       =>   33     END.
>            34
>            35   ON 'choose':U OF done IN FRAME mainMenu
>            36       APPLY "close" TO THIS-PROCEDURE.
>            37
>            38   ENABLE ALL WITH FRAME mainMenu.
>            39   WAIT-FOR CLOSE OF THIS-PROCEDURE.

> When the Debugger starts, you can open a procedure using File Open and then run the procedure using Debug Run.

> As a result, while the invoking procedure waits on the blocked statement, the Debugger runs on its own, allowing you to control any other procedure that you start from it.

> When you exit the Debugger, it returns control to the invoking procedure, which continues execution from the next statement (line 33 in the example). In stand-alone mode, you cannot otherwise access the invoking procedure until the Debugger returns control.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095