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:
- 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.
- Select Events and
then select PRESS from the Events submenu. The VisualAge RPG Editor
window appears.
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.
- Position the pointer anywhere on
the line including the BEGACT operation code, and click the left mouse button. This action
positions the cursor.
- Select Edit from
the menu bar, and then select Insert prompt from the pull-down menu. The
VisualAge RPG - C - Calculation window appears.
- Enter MOVE in the Operation
and Extender field.
- Enter '1' in the Factor
2 field.
- Enter *INLR in the Result
Field.
Accessing Online Help
Extensive online help is
available for the RPG language.
Follow these steps:
- Before leaving the prompt screen,
position the cursor back into the Operation and Extender field and erase MOVE.
- Press F1. A help
panel that provides a list of operation codes appears.
- 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.
- 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:
- Enter MOVE in the Operation
and Extender field.
- Click OK to add
this line of code to the source.
- To end prompting, click Cancel.
The line of code is added directly below the BEGACT statement.
- To save this change, choose the File
option from the menu bar, and then select the Save choice.
- Close the editor by
double-clicking the left mouse button on the top left-hand corner of the editor window.
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.