Previous Topic Next topic Print topic


Debug using the CodeWatch User Interface

  1. Click View and make sure Show Line Numbers is selected.
  2. Use the Find feature in the CodeWatch Debugger to find the line containing the string SYSIN_NUM_RECS. Right-click on the string and select Add 'SYSIN_NUM_RECS' to watch panel.

    This adds the variable SYSIN_NUM_RECS to a list of monitored variables. You can see all watched variables in the Exp (expression) column of the Watch list, alongside their current value. SYSIN_NUM_RECS is currently uninitialized. You can also use the Watch list to overwrite a variable's value.

    Tip: If the Watch list is not displayed, you can open it by choosing View > Watch.
  3. Use the Find feature again to find the string SYSPRINT_BUFF. Right-click on that string and select Add 'SYSPRINT_BUFF' to watch panel to set a watch on that variable.
  4. Double-click anywhere on the line that reads on error begin;.

    This introduces a breakpoint at the executable line, indicated by a red circle in the left margin.

    Tip: You can see a list of all breakpoints in the Break list (choose View > Break).
  5. Press the Continue button . Processing starts, and pauses when it reaches the breakpoint.
  6. Using the Find feature, find the line that contains ON ENDFILE (SYSUT1) and double-click anywhere on the line to introduce a new breakpoint.
  7. Press Continue again. When execution stops at that line, you can see that the watched variables remain uninitialized.
  8. Press the Step into button twice to execute the next two statements.

    Look at the Watch list to see the values of the variables at this point: the SYSPRINT_BUFF variable has changed to ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ12 following the sequence of commands to populate SYSPRINT_BUFF.

  9. Continue to press Step into to step through the code one line at a time until the line that reads line sysin num recs = '0';. This line initiates the SYSIN_NUM_RECS variable. Press Continue again and notice that SYSIN_NUM_RECS is updated in the Watch view with its initialized value of 0000.
  10. Continue to press Step into to step through the code until reaching the line after the line that reads sysin_num_recs = sysin_num_recs + 1;, at which point 1 is added to SYSIN_NUM_RECS. You can see the new value in the Watch view.
  11. Set a breakpoint on the last line of the program, contain the END statement.
  12. Press Continue.

    When the debugger reaches the END statement, you can see from the final value of SYSIN_NUM_RECS (0004) that the program has processed five records. Go back to line first line in the program containing the string SYSIN_NUM_RECS, right-click the variable name and choose View contents of '[variable name]' to view the variable's current value in a message box. You can get the value of any variable this way, not just those that are watched. For example, highlight find and select the string EOF_SYSIN and view that variable's current value.

  13. Press any of navigation buttons to execute the END statement and end the program.

When execution of the code has finished, and the program exited, the CodeWatch window closes.

Breakpoints and watches are not saved between debugging sessions, and you will have to set them again the next time you run CodeWatch, if required.

Previous Topic Next topic Print topic