Exercise 5.4: Monitoring variables

Before you begin, you must complete Exercise 5.3: Setting breakpoints.

You can monitor variables in the Monitors view. Now you will monitor the variable &count.

To monitor a variable:

  1. In the Source view, double-click the variable &count.
    Monitor Expression
  2. Right-click &count.
  3. Click Monitor Expression on the pop-up menu.

    The Monitors view opens.
    Monitor Expression

    The variable appears in the Monitors view. Its current value is zero.

    Tip: If you quickly want to see the value of a variable without adding it to the Monitor, leaving the mouse pointer on a variable for a second or so will display its value in a pop-up window.

    Now that some breakpoints are set, you can start to run the application.
    Resume icon on Debug toolbar

  4. Click the Resume Resume button icon from the Debug toolbar.

    The program starts running and stops at the breakpoint at line 8. (Be patient, the Debugger has to stop 98 times but because of the condition continues to run until the 99th time.) Notice in the Monitors view, that &count now has the value 99.

  5. Click the Resume icon again.

    The program stops at the breakpoint at line 8 again and &count now has the value 100.

  6. Click the Resume icon once more so that the program runs to the breakpoint at line 11.

    If you do not see the error message below, go to Exercise 5.5: Stepping into a program.

    Error Handling

    If you forget to add the parameter to the CALL program command when you debug the program, you will see this error message.
    Debugger message MCH3601

    1. Click OK.
    2. Click the Terminate Resume button icon on the Debug toolbar.

      The debug session terminates on the workstation but the exception waits for input from the 5250 emulation session.

      If you closed the Debug view by mistake, you will need to re-open the Debug view and then terminate the debug session on the workstation.
      Debug view closed

      Click Window > Show View > Debug.
      Open Debug view again
      Remember to terminate the Debug view if you haven't done so already.

    3. Go to your 5250 emulator and press Enter until the program messages complete and the Remote System Explorer communications server screen appears again.
      5250 program messages
    4. In the workbench, click the Remove all terminated launches icon on the Debug toolbar to clean up the Debug view.
      Remove all terminated launches button
    5. Click the arrow beside the Debug icon on the workbench toolbar to start a new debug session.
    6. Select Debug from the list.
      Debug icon

      The Debug Launch Configurations window opens.
      Fix parameter

    7. Click the How To Start tab.

      The How To Start page opens.
      Debug: How to start section

      By default, the page contains a call for the program selected in the Remote Systems view.

    8. Click Prompt.

      The Call Program (CALL) window opens.
      Call Program window

    9. In the Parameters field, type 'XX' where 'XX' is your workstation number. Click Add.

      The parameter value will appear in the lower list.

    10. Click OK.
    11. Click Debug.

      If you did not terminate the debug session, you will see this error message.
      CPF3501 message

      Complete the steps shown earlier in the section called Error Handling to terminate the debug session then start the debug session again by clicking the arrow beside the Debug icon on the workbench toolbar and selecting CLC1 from the list. Breakpoints and monitors are restored.

You have monitored the variable &count and now you are ready to begin Exercise 5.5: Stepping into a program.