3.1 Adding an Action Subroutine for Exit

Now that you have finished designing the Customer Inquiry window and have a new project, you can add some code to give the window functionality. Let's first add a subroutine for the EXIT push button.

Adding an Action Subroutine

Follow these steps:

  1. Select the EXIT push button part with the left mouse button. Click the right mouse button to view the pop-up menu for this part.
  2. Select Events and then select PRESS from the Events submenu. The VisualAge RPG Editor window appears.
  3. When the editor first appears the BEGACT and ENDACT subroutine statements have already been put into the subroutine. In addition, there is a comment line to support documentation. You can type directly into this area to include any further information you might think is necessary.

    Although the framework for the RPG code has been built, the application logic is not there and must be added. You need to add the code to support an Exit operation.

  4. Position the pointer anywhere on the line including the BEGACT operation code, and click the left mouse button. This action positions the cursor.
  5. Select Edit from the menu bar, and then select Insert prompt from the pull-down menu. The VisualAge RPG - C - Calculation window appears.

Accessing Online Help

Extensive online help is available for the RPG language.

Follow these steps:

  1. Before leaving the prompt screen, position the cursor back into the Operation and Extender field and erase MOVE.
  2. Press F1. A help panel that provides a list of operation codes appears.
  3. Scroll through the list of operation codes until MOVE is in view. Double click over the MOVE line and a second help panel appears showing detailed help for the MOVE operation.
  4. To close the help panel, double-click on the icon at the top left-hand corner of the window.

Ending and Saving Prompts

Next, lets end prompting and save the code.

Follow these steps:

  1. Enter MOVE in the Operation and Extender field.
  2. Click OK to add this line of code to the source.
  3. To end prompting, click Cancel. The line of code is added directly below the BEGACT statement.
  4. To save this change, choose the File option from the menu bar, and then select the Save choice.
  5. Close the editor by double-clicking the left mouse button on the top left-hand corner of the editor window.
  6. The event-driven method of creating applications means that the program is controlled by the events selected from the window. An event can be linked to an action subroutine. Action subroutines start with a BEGACT operation code and end with an ENDACT operation code. The logic found in between these two lines is the business logic executed when the event is selected.

Click on to indicate that you've done all the steps.