Setting breakpoints

A breakpoint is a point in your application code where you want to interrupt the normal execution of the application while you are debugging. If you suspect a problem is occurring in a particular script or function call, set a breakpoint at the beginning of the script or at the line where the function is called.

When you close the debugger, any breakpoints you set are written to your PocketBuilder initialization file and are available when you reopen the debugger.

Setting a simple breakpoint

This procedure describes setting a breakpoint in the Source view in the debugger. You can also set a breakpoint by selecting Add Breakpoint from the pop-up menu in the Script view when you are not running the debugger.

StepsTo set a breakpoint on a line in a script:

  1. Display the script in a Source view and place the cursor where you want to set the breakpoint.

    For how to change the script shown in the Source view, see “Using the Source view”.

  2. Double-click the line or select Add Breakpoint from the pop-up menu.

    PocketBuilder sets a breakpoint and a red circle displays at the beginning of the line. If you select a line that does not contain executable code, PocketBuilder sets the breakpoint at the beginning of the next executable statement.

Setting special breakpoints

Breakpoints can be triggered when a statement has been executed a specified number of times (an occasional breakpoint), when a specified expression is true (a conditional breakpoint), or when the value of a variable changes.

You use the Edit Breakpoints dialog box to set and edit occasional and conditional breakpoints. You can also use it to set a breakpoint when the value of a variable changes. The Edit Breakpoints dialog box opens when you:

Setting occasional and conditional breakpoints

If you want to check the progress of a loop without interrupting execution in every iteration, you can set an occasional breakpoint that is triggered only after a specified number of iterations. To specify that execution stops only when conditions you specify are met, set a conditional breakpoint. You can also set both occasional and conditional breakpoints at the same location.

StepsTo set an occasional or conditional breakpoint:

  1. On the Location tab in the Edit Breakpoints dialog box, specify the script and line number where you want the breakpoint.

    You can select an existing location or select New to enter a new location.

    NoteSet a simple breakpoint first You must specify a line that contains executable code. Set a simple breakpoint on the line before opening the Edit Breakpoints dialog box to make sure the format and line number are correct.

  2. Specify an integer occurrence, a condition, or both.

    The condition must be a valid boolean PowerScript expression. If it is not, the breakpoint is always triggered. PocketBuilder displays the breakpoint expression in the Edit Breakpoints dialog box and in the Breakpoints view. When PocketBuilder reaches the location where the breakpoint is set, it evaluates the breakpoint expression and triggers the breakpoint only when the expression is true.

Setting a breakpoint when a variable changes

You can interrupt execution every time the value of a variable changes. The variable must be in scope when you set the breakpoint.

StepsTo set a breakpoint when a variable changes:

  1. Do one of the following:

    The new breakpoint displays in the Breakpoints view and in the Edit Breakpoints dialog box if it is open. PocketBuilder watches the variable during execution and interrupts execution when the value of the variable changes.

Disabling and clearing breakpoints

If you want to bypass a breakpoint for a specific debugging session, you can disable it and then enable it again later. If you no longer need a breakpoint, you can clear it.

StepsTo disable a breakpoint:

  1. Do one of the following:

    The red circle next to the breakpoint is replaced with a white circle.

    You can enable a disabled breakpoint from the pop-up menus or by clicking the white circle.

NoteDisabling all breakpoints To disable all breakpoints, select Disable All from the pop-up menu in the Breakpoints view.

StepsTo clear a breakpoint:

  1. Do one of the following:

    The red circle next to the breakpoint disappears.

NoteClearing all breakpoints To clear all breakpoints, select Clear All in the Edit Breakpoints dialog box or from the pop-up menu in the Breakpoints view.