5.2 Working with Action Links

So far you have written logic for each event. VisualAge RPG has the ability to allow different events to invoke the same action subroutine. To illustrate this you will add a menu to the Customer Inquiry window CUSTINQ with an Exit menu item. When you select the Exit menu item the program terminates by invoking the code that is run when you click EXIT.

Follow these steps:

  1. Select the Menu bar part on the Parts Palette and click on the Customer Inquiry window CUSTINQ in the Project window.
  2. Go to the tree view of your project and locate the Menu bar part just added. Click on the '+' sign next to it to see the menu items.
  3. Double-click on the first menu item to open its Properties notebook.
  4. Change the label value to File.

    Click OK.

  5. Add the Exit menu item to the file menu by selecting the sub-menu item part on the Parts Palette and clicking on the File menu item in the Project window.
  6. Submenus and menu items must be placed in the Project window, not the Design window.

  7. Double-click on the new menu item you just created to open its Properties notebook. Change the name of this menu item to MIEXIT and its label to Exit. Click OK.

Linking Events

Now you can link the MENUSELECT event of the Exit menu item to the PRESS event of the EXIT push button.

Follow these steps:

  1. Select Project > Edit action subroutines from the menu bar. The Action subroutines window displays.
  2. From the Windows list box select CUSTINQ by clicking on it with the left mouse button.
  3. This action fills the Parts list box with all the parts on the window. Since you are interested in the events for the MIEXIT window, select it from the Parts list box.
  4. You now see the Events list box filled with all events for a menu item. Choose the MENUSELECT event in the Events list box, then select PSBEXIT+PRESS+CUSTINQ in the Action subroutines list box. The Create link push button is now enabled.
  5. Click on the Create link push button. This links the MENUSELECT event to the PRESS event action subroutine.
  6. Close this window by clicking Close. Then close the editor.
  7. Build your application and test it. You can now end the application by clicking EXIT or by choosing File > Exit from the menu bar.

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