Step Through Source Code

Set a Breakpoint Tutorial Contents Examine Data

Run the program and step to see where the errors is occurring.

  1. Click the Run button.

    The Applet Viewer appears and when the breakpoint is reached, line 61 is highlighted and a right-facing arrow is displayed in the Annotation column,

    <PIC>

  2. Click the Step Into button.

    <pic>

  3. Click the Step Over button twice.

    You are using the Step Over button to avoid stepping into the code that generates the width of the menu items. As you step through the source code, you can evaluate each variable by selecting it. If the variable is in scope, after a brief delay a popup window appears displaying the current variable value.

  4. Double-click the variables listed below to display their values in a popup label:
    curlen 58
    menulinks an array of four instances of QMenuLink

    These values tell you that the length of the current instance of QMenuLink (the current menu item) is 58.

  5. Click the Step Into button twice.

    The variable menuwidth gets set to 58, the width of the current menu item. Notice that line 68 sets menuwidth to 10. This is the problem. This line of code should be adding 10 to the width of the widest menu item.

  6. Change line 68 to read:
    this.menuwidth += 10;
    
  7. Choose File > Save to save your change.
    Set a Breakpoint Tutorial Contents Examine Data

    Guide to the Cosmo Code Development Environment
    12-96*160