Debug the Hello PL/I World Application

Walks you through the process of modifying your application in Visual Studio, and then debugging it using the Visual Studio debugger.

Modify your application

Here, you modify the code of the original HelloWorld program for the purposes of this demonstration:

  1. In the program editor, add the following code on the line before the put skip list statement:
      DCL SourceString    CHAR(10);
      DCL testchar        CHAR;
      DCL loop            FIXED BIN(8);
      
      SourceString = "AAbbAAbbCC";
      DO loop = 1 TO 10 BY 1;
        testchar = SUBSTR(SourceString, loop, 1);
        IF testchar = "A" THEN
          SUBSTR(SourceString, loop, 1) = "D";
      END;
      PUT SKIP LIST(SourceString);
      
      loop = 1;
      DO WHILE (loop < 10) UNTIL (SUBSTR(SourceString, loop, 1) = "C");
        SUBSTR(SourceString, loop, 1) = "Q";
        loop = loop + 1;
      END;

    The SourceString variable is a string that has an initial value of AAbbAAbbCC. Some of the string characters are replaced during the execution of this program.

  2. Save the changes.
  3. In the Solution Explorer, right-click the project, and then select Build > Rebuild from the context menu.

    This recompiles the code with your changes.

  4. Check the Output window to be sure that the project recompiled without errors.

Set breakpoints

Before starting the debugger, set a breakpoint to stop program execution before exiting the console so you can see the output.

  1. In the program editor, click in the left-most column on line 8, which reads:
    DO loop = 1 TO 10 BY 1;

    A dot appears in the column to indicate the breakpoint.

  2. Now, click in the left-most column on the last line of the program, which reads:
    end HelloPLIWorld;

    Again, a dot appears in the column to indicate the breakpoint.

Open the Watch window

As you debug, you can watch the value of a data item in the Watch window.

  • On the main menu in Visual Studio, click Debug > Windows > Watchpoints.

    This opens the Watchpoint window below the program editor window.

Debug HelloWorld.pli

Enterprise Developer uses the Visual Studio debugger to debug PL/I applications.

  1. Press F5.

    Visual Studio builds the program and starts the debugger. The program launches the console window, and then execution stops on DO loop = 1 TO 10 BY 1;.

    Tip: Resize the Visual Studio IDE and the console window so you can view them simultaneously.
  2. In the Watch 1 window, click Add item to watch.
  3. Type SourceString, and then press Enter.
  4. To step through the loop, press F10 until you reach the END statement on line 12.

    Notice how the value of SourceString changes.

  5. Press F5.

    The debugger runs the program through to the second breakpoint. Notice that the console shows Hello PL/I World!

  6. Press F5 to run the program to its end.

    The debugger closes and returns you to the Visual Studio editor.

  7. Optionally click File > Save All to save this project for future reference.

This completes the tutorial.