Develop the Program1 Application

Guides you through a process of changing and testing the Program1 applications.

Introduce errors

To get a feel for how errors are handled by the compiler, introduce some errors into the application.

  1. If sub.pli isn't already open in the Visual Studio editor, double-click it in the Solution Explorer.
  2. Add a1 = fred; to the source code.
  3. Remove end sub;.
  4. Add Invalid command.
  5. Save your changes.

Rebuild the PLIProgram project

  • On the Solution Explorer, right-click the PLIProgram project, and select Rebuild from the context menu.
    Note: Build only regenerates files that have changed. Rebuild first cleans out all generated files and performs a clean build of everything.

    The Output window shows the progress of the build process.

Review errors and warnings

  1. Check the Error List window to see that two errors have been reported.
  2. Double-click an error message to go directly to the errors in the code by double-clicking the error messages in the window.

Undo changes

To undo the errors introduced into your code:

  1. Place your cursor in the Visual Studio editor window for the sub.pli program.
  2. Press Alt+Backspace twice to revert to the original code.
  3. Rebuild the project.

Add a new include file

  1. In the Solution Explorer, right-click the PLIProgram project, and then select Add > New Item from the context menu.
  2. In the left pane, click PL/I Items, and then click PL/I Include.

    The default name of the file is Include1.inc.

  3. Click Add.

Add code to the include file

  1. In the Solution Explorer, double-click the Include1.inc file to open it in the editor.
  2. Replace the contents with the following:
    /* Micro Focus Open PL/I Include File */
      put skip list ('jim', MSG);
  3. Save the file.

Update Include1.inc properties

  1. Click Include1.inc in the Solution Explorer and look at the Properties window directly beneath the Solution Explorer.

    Notice the value of the Build Action option is set to the default value of None. You need to change this to Content.

  2. Use the drop-down menu to change the value of be Build Action field to Content.

Update Program1.pli

  1. Switch to the editor tab for Program1.pli.
  2. Replace the contents with the following:
    /* Micro Focus Open PL/I Console Application */
     %replace MSG by 'From include - main';
     Program1: proc options (main);
       dcl sub entry;
       dcl a1 char(14);
       put skip list ('Hello world - main' );
       %include 'Include1.inc';
       call sub();
       put skip;
       get list (a1);
      
     end Program1;
  3. Save your changes.

Update sub.pli

  1. Switch to the editor tab for sub.pli.
  2. Replace the contents with the following:
    /* Micro Focus Open PL/I program */
     %replace MSG by 'From include - sub';
    
    sub: proc;
       put skip list ('Hello world sub' );
       %include 'Include1.inc';
    end sub;
  3. Save your changes.

Edit the project configuration

  1. In the Solution Explorer, double-click the Properties entry to open the project Properties page..
  2. On the PL/I tab in the General section, set Enable Macro Preprocessor to Yes.
  3. Click File > Save All to save your changes.

Rebuild the project

  1. Click Build > Rebuild Solution and inspect the Output window. This will compile both Program1.pli and sub.pli.
  2. On the menu bar, click Build > Build Solution. You will now get the following message in the output window:
    		Program1.pli is up-to-date
    		sub.pli is up-to-date
    		PL/I compile: 2 item(s) succeeded or up-to-date, 0 failed.

    If you change one of the source files and then click Build > Build Solution, only that program will be compiled.

    If you change the include file both programs will be compiled because it is included in both of them. Any program that does not use the include file will not be recompiled.

This completes the tutorial.