Add breakpoints in application scripts

Note

Now you open the Debugger and add breakpoints to examine the behavior of the login and Customer windows. When PowerBuilder runs the application in debug mode, it stops just before executing a line containing a breakpoint.

When you insert breakpoints in a script, you should select lines that contain executable statements. If you try to set a breakpoint in variable-declaration lines, comment lines, or blank lines, PowerBuilder sets the breakpoint at the next executable line.

Debug button in the Debugger
  1. Click the Debug button in the PowerBar.

    PowerBuilder opens the Debugger. There are three stacks of tabbed panes in the default view layout scheme. The Source view is visible in a single pane at the top left of the Debug window. The Source Browser view is open in the pane at the top right.

    NoteIf the Debug window looks different If you have opened the Debug window before and opened, moved, or closed any views, your display may look different. To restore the default view layout scheme, select View>Layouts>Default from the menu bar.

    Shown is the default view layout scheme of the Debug window. At top left is the Source view showing code for the p b tutor event open ( string command line ). At top right, the Source Browser tab page is shown with  Application and p b tutor expanded. The open event of p b tutor is highlighted. Hidden at top right is the Source History tab. At bottom left are tabs for Local, Global, Instance, Parent, Shared, and Objects in Memory. At bottom right are tabs for Call Stack, Break points, and Watch.

    The source code for the application Open event displays in the Source view at top left. If it does not display, expand the Application node in the Source Browser view’s tree view and double-click the Open event under the pbtutor application.

  2. In the Source view, double-click the line containing the following assignment statement:

    this.ToolBarSheetTitle = "MDI Application Toolbar"
    

    A red symbol displays at the start of the line to show that a breakpoint has been set on the statement.

    Shown is the Source view displaying code for the p b tutor event open ( string command line ). A dot signifying a break point appears to the left of the following line : this dot Tool Bar Sheet Title equals " M D I Application Tool bar "
  3. Expand the following node in the Source Browser view: Windows>w_welcome>cb_ok

    The Source Browser view lists only events that have been coded. The only event for the login window OK button is the Clicked event.

  4. Double-click the Clicked event for the cb_ok button in the Source Browser view.

    The code for the Clicked event displays in the Source view.

  5. Double-click the following line:

    gnv_connect = CREATE & 
    
    			n_pbtutor_connectservice
    

    A breakpoint symbol displays at the start of the line.

    Shown is the code for the Clicked event for the d b _ o k button in the Source view. A dot signifying a break point appears to the left of the following line: g n v _ connect equals Create n _ p b tutor _ connect service
  6. Double-click w_master_detail_ancestor in the Source Browser view.

    Double-click dw_master, then rowfocuschanged.

    PowerBuilder displays the script for the RowFocusChanged event of the dw_master DataWindow control in the Source view.

  7. Double-click this line:

    IF dw_detail.Retrieve(ll_itemnum) = -1 THEN
    

    A breakpoint symbol displays at the start of the line.

  8. Select the Breakpoints tab in the lower-right stack.  

    Shown is the Debugger window for p b tutor. At top left is the Source view showing code for the row focus changed event of the d w _ master Data Window control. At top right is the Source Browser with the row focus changed event highlighted. At bottom right is the Break points tab page with three lines of code and a break point symbol to the left of each.

    You should see the breakpoints you set in the Breakpoints view. To complete this lesson, you need to have these breakpoints set correctly.

    NoteIf you have additional breakpoints You can clear any excess breakpoints using the pop-up menu in the Breakpoints view.