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.
- If
sub.pli isn't already open in the Visual Studio editor, double-click it in the
Solution Explorer.
- Add
a1 = fred; to the source code.
- Remove
end sub;.
- Add
Invalid command.
- Save your changes.
Rebuild the PLIProgram project
Review errors and warnings
- Check the
Error List window to see that two errors have been reported.
- 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:
- Place your cursor in the Visual Studio editor window for the
sub.pli program.
- Press
Alt+Backspace twice to revert to the original code.
- Rebuild the project.
Add a new include file
- In the
Solution Explorer, right-click the
PLIProgram project, and then select
Add > New Item from the context menu.
- In the left pane, click
PL/I Items, and then click
PL/I Include.
The default name of the file is
Include1.inc.
- Click
Add.
Add code to the include file
- In the
Solution Explorer, double-click the
Include1.inc file to open it in the editor.
- Replace the contents with the following:
/* Micro Focus Open PL/I Include File */
put skip list ('jim', MSG);
- Save the file.
Update
Include1.inc properties
- 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.
- Use the drop-down menu to change the value of be
Build Action field to
Content.
Update
Program1.pli
- Switch to the editor tab for
Program1.pli.
- 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;
- Save your changes.
Update
sub.pli
- Switch to the editor tab for
sub.pli.
- 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;
- Save your changes.
Edit the project configuration
- In the
Solution Explorer, double-click the
Properties entry to open the project
Properties page..
- On the
PL/I tab in the
General section, set
Enable Macro Preprocessor to
Yes.
- Click
File > Save All to save your changes.
Rebuild the project
- Click
Build >
Rebuild Solution and inspect the
Output window. This will compile both
Program1.pli and
sub.pli.
- 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.