Previous Topic Next topic Print topic


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. Open the helloworld.pli program in the editor.
  2. Add the following code before the line for 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 in order to recompile the code with your changes.

    There should be no errors in the build.

Start debugging

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

  1. Press F5 to start debugging.

    Visual Studio starts debugging and loads a number of windows. It also starts the CodeWatch debugger window. The debugger displays the HelloWorld program and moves to the second line of the program code. A Java CodeWatch terminal log window also appears. Both windows might be minimized to the task bar.

  2. Right-click on the SOURCE-STRING item and click Add SourceString to Evaluation panel.
  3. Press F11.

    This executes the statement which initializes the value for SOURCE-STRING.

  4. Step through the next few lines in the same way and see how the value of the SOURCE-STRING variable changes.
  5. Press F5 to exit the program.

    Debugging stops and control is returned to the Visual Studio IDE.

You can save the project for future reference.

Previous Topic Next topic Print topic