3.7 Syntax Checking

When you enter source, you want to identify and correct syntax errors as you enter the source. Automatic syntax checking is, by default, turned on for ILE RPG source.

When automatic syntax checking is turned on, the syntax of each line of source code is checked automatically when you make a change to the line and move the cursor off of that line.

First, lets turn automatic syntax checking off. Then lets insert some errors into the source and then use the syntax feature to find these errors in the file.

Follow these steps:

  1. Select the Options >Language editing and then deselect Syntax checking.
  2. Move the cursor to row 78, column 29.
  3. Check the ruler to make sure the Editor is in Replace mode. Now, create an error by typing an X over the character E in the word MOVE.
  4. Move the cursor to row 122, column 64.

  5. Create an error by typing 10 in the length column for the MOVE function.
  6. Move the cursor to row 1. Select the Actions menu bar choice, then select Syntax check file.
  7. Press Alt+N to move your cursor to the first error in the file.
  8. Correct the error by typing the character E back into the word MOVE.
  9. Move the cursor off the row you just fixed. The error message remains.
  10. Press Alt+N to move your cursor to the next error in the file.
  11. This error results because the Len columns is not blank. To fix this error, remove the number 10 from the columns.
  12. To see help for an error message, place your cursor on an error message and press F1. This opens a window with help for the error. Select Close from the system menu to close the help window.

  13. Move the cursor off the row you just fixed. The error message remains.
  14. Select Actions > Delete messages to delete the messages from the file.
  15. Press Ctrl+S to save and upload the changes to AS/400.
  16. Select the Options > Language editing and then select Syntax checking. Automatic syntax checking is now enabled.
  17. Click on to indicate that you've done all the steps.

This completes Exercise 3. You should now be familiar with the CODE Editor features such as prompts,format lines and syntax checking when editing ILE RPG source.

Next you verify and compile the ILE RPG/400 source for the Customer Inquiry application.

But before you do, we recommend you do the Quiz.