Tutorial: Debug the Hello PL/I World Application

This tutorial uses the PL/I program and project you created in the tutorial Creating Your First Hello PL/I World Application to demonstrate the basics of debugging using Visual Studio.

Modify your application

You are going to modify the code of the original HelloWorld program for the purposes of this demonstration:

  1. In the Solution Explorer, double-click the HelloWorld.pli program to open it in the Visual Studio editor.
  2. 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.

  3. Click Build > Rebuild Solution to recompile the code with your changes.

    There should be no errors in the build.

Set a breakpoint

Here you set a breakpoint to stop program execution before exiting the console so you can see the output.

  • In the program editor, scroll down to the bottom of the program, and set a breakpoint on the last line (end HelloWorld;) by clicking in the left-most column.

    A dot appears in the column to indicate the breakpoint.

Debug HelloWorld.pli

Enterprise Developer uses the Visual Studio debugger to debug PL/I applications. To start debugging:

  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.

    The debugger also starts a Watchpoints window where you can watch the value of the SourceString data item.

  2. To step through the loop, press F10 multiple times. Notice how the value of SourceString changes.
  3. Press F5.

    The debugger runs the program through to the second DO statement.

  4. Press F5 several times until the debugger stops on your breakpoint. Notice that the console shows Hello PL/I World!
  5. Press F5 to run the program to its end.

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

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